![]() |
| | #1 |
| Registered User Join Date: Nov 2009
Posts: 2
| "Expected undefined-id" Error Message I am writing a simple code to make sure I understand classes, and am getting the error message: Code: error: expected unqualified-id before âintâ Code: #include <iostream>
using namespace std;
class firstclass
{
public:
firstclass();
int sum( int x, int y );
~firstclass();
};
firstclass::firstclass()
{
int z = 0;
}
firstclass::int sum( int x, int y)
{
z = x + y;
return z;
}
firstclass::~firstclass()
{
}
int main()
{
firstclass math;
int a = 0;
int b = 0;
cout<<"Enter two numbers: First: ";
cin>> a ;
cout<<"\nSecond";
cin>> b ;
cout<<"The sum is"<<math.sum( a, b )<<"";
}
|
| FlyingShoes12 is offline | |
| | #2 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Writing a member function doesn't look like Code: firstclass::int sum( int x, int y) Code: int firstclass::sum( int x, int y) |
| tabstop is offline | |
| | #3 |
| Registered User Join Date: Jun 2009
Posts: 2
| thank you it works perfectly |
| FlyingShoes is offline | |
![]() |
| Tags |
| error |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Undefined Reference Compiling Error | AlakaAlaki | C++ Programming | 1 | 06-27-2008 11:45 AM |
| C OpenGL Compiler Error? | Matt3000 | C Programming | 12 | 07-07-2006 04:42 PM |
| c++ linking problem for x11 | kron | Linux Programming | 1 | 11-19-2004 10:18 AM |
| Problem with OpenGL tutorial | 2Biaz | Windows Programming | 18 | 09-16-2004 11:02 AM |
| qt help | Unregistered | Linux Programming | 1 | 04-20-2002 09:51 AM |