Dear my friend, Daryl....
Yessss....!!! Your example code is very usefull... I
understand now.
After I tried to understand your code, I modified my
code (but firstly without making the class in the
separated header files) and it run properly.
Than I tried to improve my code with separated header
files... and it runs propely...
Thanks Daryl... Thank you for your patience helping me
on my first step.
ps. Now I am doing a lot of homework at home for doing
practices from a GNU C++ book. Next time I am going to
come here with a more qualified question.
--- Daryl Lee
See my comments inline below
Dear Paul.
I am still confused. Sorry I am a really beginner in GNU C++. 1. May I make 2 classes in one file? You may declare (and define) as many classes as you
On Thu, Sep 30, 2004 at 06:16:10AM -0700, Prabu Subroto wrote: like. If you have Java experience, this may seem strange, but this isn't Java.
2. header is somewhat like this : "#include
. I am confused how should the header file of my "menu" class for registering "samba" class in the "menu" class? Could you give me an example of the header file of my "menu" class please....?
I took the liberty of reorganizing and reformatting your code. It is at the bottom of this message. I also took the liberty of repairing a defect you haven't encountered yet. Note the removal (by commenting it out) of the FOR loop in samba::tamil(). Finally, I removed the .h from #include
and added a "using namespace std". Your code now compiles silently. Thank you very much in advance. --- Paul Howie
wrote: You need to pre-declare the class samba.
Just moving it above the main method should do
trick, but you might want to declare it in a header file for safety.
Paul
On Thu, 30 Sep 2004 05:16:01 -0700 (PDT), Prabu Subroto
wrote: Dear my friends..
I am practicing GNU C++ on SuSE 9.1.
But if I compile my code I got this error message as below: ==== patrixlinux@patrix:~/arsip/proyek/gcc/liss> g++ -o liss ./liss.cpp In file included from /usr/include/g++/backward/iostream.h:31, from liss.cpp:1:
warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of
/usr/include/g++/backward/backward_warning.h:32:2: the
C++ standard. Examples include substituting
header for the
header for C++ includes, or <sstream> instead of the deprecated header . To disable this warning use -Wno-deprecated. liss.cpp: In member function `void liss.cpp:19: error: `samba' undeclared (first use
<X> menu::tampil()': this
function) liss.cpp:19: error: (Each undeclared identifier is reported only once for each function it appears in.) liss.cpp:19: error: `s' undeclared (first use
the the this
function) liss.cpp:19: error: syntax error before `(' token liss.cpp: At global scope: liss.cpp:39: error: `struct samba' used prior to declaration patrixlinux@patrix:~/arsip/proyek/gcc/liss> ====
Why is it so?
Thank you very much in advance.
ps.Sorry for my stupid question. ==== Here is my code. ==== #include
#include #include class menu { public: char pilihan; void tampil();
};
void menu::tampil(){ for (;;){ cout << "Menu : (S)amba (P)ostfix (B)ind (Q)uit\n"; cin >> pilihan; switch ( toupper(pilihan) ){ case 'S': cout << "You are administrating Samba Server" << endl; samba * s = new samba(); s->tampil();
break; case 'P': cout << "You are administrating Postfix Server" << endl; break; case 'B': cout << "You are administrating BIND Server" << endl; break; case 'Q': cout << "You selected Quit. Good bye!" << endl; exit(0); default: cout << "***No such command!***" << endl; break; } } }
class samba { public: char resource[50]; void tampil(); };
void samba::tampil(){ for(;;){ cout << "Share file or directory: "; cin >> resource; } }
int main(){ menu * m = new menu(); m->tampil(); return 0; }
New, improved version:
#include <iostream> #include
#include using namespace std; class menu { public: char pilihan; void tampil();
};
class samba { public: char resource[50]; void tampil();
=== message truncated === __________________________________ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail