4 Replies - 2328 Views - Last Post: 10 December 2010 - 06:07 PM Rate Topic: -----

#1 jayjay12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-December 10

Visual c++ 2010

Posted 10 December 2010 - 11:32 AM

Here is my problem...


1. Create the Employee example in this lesson.
2. Implement a virtual function CalcPay(), they should work as follows:
In the Commission class it should return the base amount +(salesAmount * commRate)
In the Salary class, if the pay grade is 1 just return the base pay. If the pay grade is 2 return the base pay + (base pay * .19) if the base pay is 3, return the base pay + (base pay * .23)
3. Create an Employee object a Salary object and a commission object to illustrate the polymorphic behavior of the CalcPay() class. Output the results to the screen.


I have done my share of the coding however.. I am suppose to make it in Visual c++ 2010... im not really sure how to use the software.




class comssion
{
private:
long int base,sales;int rate
public:
int clac()
{
cin>>base>>sales>>rate;
return(base+(sales*rate));
}
}c;
class salary
{
long int base; int grade;
public:
int grade()
{
cin>>grade;
cin>>base;
if(grade==1)
return(base);
else if(grade==2)
return(base+(base*.13));
else if(grade==2)
return(base+(base*.23));
}
}s;
class employee
{
public:
void calcpay()
{
long int a=c.calc();
long int b=s.grade();
}
}e;
void main()
{
e.calcpay();
}



Is This A Good Question/Topic? 0
  • +

Replies To: Visual c++ 2010

#2 wd40bomber7  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 87
  • Joined: 22-November 09

Re: Visual c++ 2010

Posted 10 December 2010 - 11:54 AM

Well Visual Studio 2010 is just a development enviroment/compiler.

First download visual studio 2010 here:
https://www.dreamspa...px?ProductId=29
(You'll need to verify that you're a student)

Install it.

Then start it up. Go file->New project

Now click Visual C++ on the left side, scroll down to Win32
Click "Win32 Console Application"
Enter a name where it says <enter_name>

click next,
uncheck precompiled header depending on your preferences
click finish,

You should see this

int _tmain(int argc, _TCHAR* argv[])
{
	return 0;
}



From there just paste your code into this file/other files depending on how you want your code separated.
Enjoy

This post has been edited by wd40bomber7: 10 December 2010 - 11:55 AM

Was This Post Helpful? 0
  • +
  • -

#3 jayjay12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-December 10

Re: Visual c++ 2010

Posted 10 December 2010 - 03:08 PM

ok i made the 3 classes.... now when i make the class "salary.h" it gives me a cpp file as well... Where do i type the code in? in the .h file or .cpp?

When i make projects without classes i usually type the code in the .cpp file. In this situation do i leave the .h file alone and only focus on the.cpp file too?
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Visual c++ 2010

Posted 10 December 2010 - 03:15 PM

Generally we:

1. Make declarations in header files.
2. Make definitions in source files.

Put your class declaration in the header file and include it in your source file as

#include "omission.h"



Or whatever you've called you header file. The define you member functions in the source file being care to specify the scope of the functions you are defining, eg:

int commision::grade()
{
    // Definition goes in here.
}



And everything should build nicely. :)
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,517
  • Joined: 23-August 08

Re: Visual c++ 2010

Posted 10 December 2010 - 06:07 PM

Things for you to read:

Getting Started with Microsoft Visual Studio 2008 Tutorial, pretty much the same as 2010.

Visual C++ Developer Center
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1