GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 12-Apr-2004, 20:12
vip3r vip3r is offline
New Member
 
Join Date: Apr 2004
Posts: 2
vip3r is on a distinguished road
Angry

Visual C++ 6 Compiler error


I've run into a compiler error in Visual C++ 6 that I can't seem to find the source of. I was thinking some of you could help me?

CPP / C++ / C Code:
class point
{
  protected:
	int positionX;
	int positionY;
  public:
	void setPositionX(int X);
	void setPositionY(int Y);
	int getPositionX();
	int getPositionY();
	point();
	point(int X, int Y);
} ;

point::setPositionX(int X)
{
	positionX = X;
}

point::setPositionY(int Y)
{
	positionY = Y;
}

point::getPositionX() 
{
	return positionX;
}

point::getPositionY()
{
	return positionY;
}

point::point(int X, int Y)
{
	positionX = X;
	positionY = Y;
}

point::point()
{
	positionX = 0;
	positionY = 0;
}
Here is the error i get:

--------------------Configuration: test - Win32 Debug--------------------
Compiling...
point.cpp
C:\Documents and Settings\Ravi\My Documents\c++tutorial\point.cpp(16) : error C2556: 'int __thiscall point::setPositionX(int)' : overloaded function differs only by return type from 'void __thiscall point::setPositionX(int)'
C:\Documents and Settings\Ravi\My Documents\c++tutorial\point.cpp(7) : see declaration of 'setPositionX'
C:\Documents and Settings\Ravi\My Documents\c++tutorial\point.cpp(16) : error C2371: 'setPositionX' : redefinition; different basic types
C:\Documents and Settings\Ravi\My Documents\c++tutorial\point.cpp(7) : see declaration of 'setPositionX'
C:\Documents and Settings\Ravi\My Documents\c++tutorial\point.cpp(21) : error C2556: 'int __thiscall point::setPositionY(int)' : overloaded function differs only by return type from 'void __thiscall point::setPositionY(int)'
C:\Documents and Settings\Ravi\My Documents\c++tutorial\point.cpp( : see declaration of 'setPositionY'
C:\Documents and Settings\Ravi\My Documents\c++tutorial\point.cpp(21) : error C2371: 'setPositionY' : redefinition; different basic types
C:\Documents and Settings\Ravi\My Documents\c++tutorial\point.cpp( : see declaration of 'setPositionY'
test.cpp
c:\documents and settings\ravi\my documents\c++tutorial\point.cpp(16) : error C2556: 'int __thiscall point::setPositionX(int)' : overloaded function differs only by return type from 'void __thiscall point::setPositionX(int)'
c:\documents and settings\ravi\my documents\c++tutorial\point.cpp(7) : see declaration of 'setPositionX'
c:\documents and settings\ravi\my documents\c++tutorial\point.cpp(16) : error C2371: 'setPositionX' : redefinition; different basic types
c:\documents and settings\ravi\my documents\c++tutorial\point.cpp(7) : see declaration of 'setPositionX'
c:\documents and settings\ravi\my documents\c++tutorial\point.cpp(21) : error C2556: 'int __thiscall point::setPositionY(int)' : overloaded function differs only by return type from 'void __thiscall point::setPositionY(int)'
c:\documents and settings\ravi\my documents\c++tutorial\point.cpp( : see declaration of 'setPositionY'
c:\documents and settings\ravi\my documents\c++tutorial\point.cpp(21) : error C2371: 'setPositionY' : redefinition; different basic types
c:\documents and settings\ravi\my documents\c++tutorial\point.cpp( : see declaration of 'setPositionY'
Error executing cl.exe.

test.exe - 8 error(s), 0 warning(s)


Thanks in advance,
ravi
Last edited by dsmith : 12-Apr-2004 at 20:44. Reason: Please enclose code in [c] & [/c] for syntax highlighting
  #2  
Old 12-Apr-2004, 20:51
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Hello vip3r. Welcome to GIDForums.

When you do the implementation of your functions, you must also give the return value.

So, it should be more like:
CPP / C++ / C Code:
class point
{
  protected:
	int positionX;
	int positionY;
  public:
	void setPositionX(int X);
	void setPositionY(int Y);
	int getPositionX();
	int getPositionY();
	point();
	point(int X, int Y);
} ;

void point::setPositionX(int X)
{
	positionX = X;
}

void point::setPositionY(int Y)
{
	positionY = Y;
}

int point::getPositionX() 
{
	return positionX;
}

int point::getPositionY()
{
	return positionY;
}

point::point(int X, int Y)
{
	positionX = X;
	positionY = Y;
}

point::point()
{
	positionX = 0;
	positionY = 0;
}
  #3  
Old 13-Apr-2004, 15:34
vip3r vip3r is offline
New Member
 
Join Date: Apr 2004
Posts: 2
vip3r is on a distinguished road

ah


Quote:
Originally Posted by dsmith
Hello vip3r. Welcome to GIDForums.

When you do the implementation of your functions, you must also give the return value.

So, it should be more like:
CPP / C++ / C Code:
class point
{
  protected:
	int positionX;
	int positionY;
  public:
	void setPositionX(int X);
	void setPositionY(int Y);
	int getPositionX();
	int getPositionY();
	point();
	point(int X, int Y);
} ;

void point::setPositionX(int X)
{
	positionX = X;
}

void point::setPositionY(int Y)
{
	positionY = Y;
}

int point::getPositionX() 
{
	return positionX;
}

int point::getPositionY()
{
	return positionY;
}

point::point(int X, int Y)
{
	positionX = X;
	positionY = Y;
}

point::point()
{
	positionX = 0;
	positionY = 0;
}

Ah, I see. Thanks for the welcome and the answer . I look forward to posting more here.
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in ukrspp21 MySQL / PHP Forum 33 02-Sep-2009 20:42
compilation error cameron C++ Forum 18 20-Feb-2004 01:41
Intel Compiler C++ for Embedded Visual C++ kiara C++ Forum 1 15-Jan-2004 10:56
Convertin C++ to eMbedded Visual C++ jbalart C++ Forum 0 23-Dec-2003 07:44
[script] E-mail webmaster error page BobbyDouglas PHP Code Library 0 19-Aug-2003 21:10

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:57.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.