Solved

New to c++

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create string splitting user defined function in C++ 23 316
How to copy an image file into clipboard C/C++? 1 196
C++ question 3 70
Need some help with mailto 16 20
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.

808 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