Solved

New to c++

Posted on 2002-05-25
2
197 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now