Solved

New to c++

Posted on 2002-05-25
2
204 Views
Last Modified: 2010-04-02
Could you tell me why I get these errors?
C:\Windows\Desktop\finally\banking.cpp(61) : error C2660: 'setnum' : function does not take 0 parameters

C:\Windows\Desktop\finally\banking.cpp(62) : error C2065: 'n' : undeclared identifier


In my void main I wrote this:
b1.setnum(int n);
n=b1.getnum();

Here is the class and the methods
class Account
{
private:
     int num;
     int type;
     float balance;
public:
     void setnum(int n);
     void settype(int t);
     void setbalance(float b);
     int getnum();
     int gettype();
     float getbalance();
};

#endif


#include "Account.h"

void Account::setnum (int n)
{
     num=n;
}
void Account::settype (int t)
{
     type=t;
}
void Account::setbalance(float b)
{
     balance=b;
}
int Account::getnum()
{
     return num;
}
int Account::gettype()
{
     return type;
}
float Account::getbalance()
{
     return balance;
}




0
Comment
Question by:deeu101
2 Comments
 
LVL 4

Accepted Solution

by:
oumer earned 50 total points
ID: 7034495
1.make sure the #endif statment in the account.h is not standalone, ie there is a maching #ifdef statment at the beginning of the file.
2. Instead of using this
//This is wrong, as you don't have to specify the argument
//type, in this case int, when you call a method or a
//function
   b1.setnum(int n);

   n= b1.getnum()

use

int n;
n= (set it to something);
b1.setnumb(n);
n=b1.getnumb();
0
 
LVL 8

Expert Comment

by:fl0yd
ID: 7035156
Don't use
void main( int nArg, char* pArg[] ) {
}

In the c++-standard the correct definition does return an int:
int main( int nArg, char* pArg[] ) {

return 0;
}
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question