Solved

New to c++

Posted on 2002-05-25
2
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

696 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