1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;
class Calc
{
private:
int m_nvalue;
public:
Calc() { m_nvalue = 0; }
void add(int nvalue);
void sub(int nvalue);
void mult(int nvalue);
int getvalue() { return m_nvalue; }
};
void Calc::add(int nvalue)
{
m_nvalue += nvalue;
}
void Calc::sub(int nvalue)
{
m_nvalue -= nvalue;
}
void Calc::mult(int nvalue)
{
m_nvalue *= nvalue;
}
int main()
{
Calc ccalc;
ccalc.add(5);
ccalc.sub(2);
ccalc.mult(3);
cout<< getvalue() << endl;
return 0;
}
|
when i built it, it showed the following errors:
1>------ Build started: Project: rough, Configuration: Debug Win32 ------
1> rough.cpp
1>e:\c programs\rough\rough\rough.cpp(17): error C3872: '0xa0': this character is not allowed in an identifier
1>e:\c programs\rough\rough\rough.cpp(18): error C2144: syntax error : 'void' should be preceded by ';'
1>e:\c programs\rough\rough\rough.cpp(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\c programs\rough\rough\rough.cpp(20): error C3872: '0xa0': this character is not allowed in an identifier
1>e:\c programs\rough\rough\rough.cpp(22): error C2144: syntax error : 'int' should be preceded by ';'
1>e:\c programs\rough\rough\rough.cpp(22): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\c programs\rough\rough\rough.cpp(46): error C3861: 'getvalue': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
please help me in sorting out the errors!!!