-   Linux - Newbie (
-   -   compilation error for c++ code (

akhirul 03-29-2013 05:09 AM

compilation error for c++ code
I am getting the below error, when i am trying to compile code below.

Error: main.cpp: In function ‚int main()‚:
main.cpp:6: error: ‚display‚ was not declared in this scope

class Test
friend int display();


int display()
cout<<"Hello:In"<< endl;
return 0;


int main()
return 0;

Strange thing is I am able to compile in unix successfully , but in linux OS getting this error.
I am using gcc and g++ compiler

pan64 03-29-2013 05:28 AM

please use [code]your code[/code] to keep formatting.
class Test is not in use at all.
I would like to see how can you compile it successfully and how it went wrong. (what was the OS, the command and the result)

bloody 03-29-2013 06:20 PM

The class refers to a function named "display" which is not defined at that point. Also, class "Test" is not created or used anywhere in the code, so why not delete the entire "class Test" thing?

John VV 03-30-2013 12:54 AM


from that you copied "test1.h" into /usr/include
the < > tell it to look there
and NOT in the build folder

if test1.h is in the same folder as main.cpp use

#include "test1.h"

All times are GMT -5. The time now is 11:55 AM.