Solved

New to c++

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

691 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