| | |
SMS(student managent system)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
> how to link classes with each other?
classes are types. are you looking for how to implement a typelist?
a tutorial introduction to typelists: http://www.ddj.com/cpp/184403813?_requestid=1305388
you might then want to read Alexandrescu's Modern C++ Design (Addison-Wesley Longman, 2001).
and look up Boost.MPL http://www.boost.org/doc/libs/1_35_0...doc/index.html which has a ready made framework for template metaprogramming. eg.
classes are types. are you looking for how to implement a typelist?
a tutorial introduction to typelists: http://www.ddj.com/cpp/184403813?_requestid=1305388
you might then want to read Alexandrescu's Modern C++ Design (Addison-Wesley Longman, 2001).
and look up Boost.MPL http://www.boost.org/doc/libs/1_35_0...doc/index.html which has a ready made framework for template metaprogramming. eg.
c++ Syntax (Toggle Plain Text)
#include <boost/mpl/vector.hpp> #include <boost/mpl/push_front.hpp> #include <boost/mpl/push_back.hpp> #include <boost/mpl/replace.hpp> #include <boost/mpl/at.hpp> #include <boost/mpl/int.hpp> #include <boost/mpl/assert.hpp> class A{} ; class B{} ; class C{} ; class D{} ; class E{} ; int main() { using namespace boost ; typedef mpl::vector<A,B> seq_ab ; typedef mpl::push_front< seq_ab, C >::type seq_cab ; typedef mpl::push_back< seq_cab, D >::type seq_cabd ; typedef mpl::replace< seq_cabd, B, E >::type seq_caed ; BOOST_MPL_ASSERT( ( mpl::is_same< mpl::at< seq_caed, mpl::int_<2> >, E > ) ) ; }
•
•
•
•
There are many classes which must be link or in other words put together in order to work as one big class.
C++ Syntax (Toggle Plain Text)
class base { // blabla }; class derived : public base { // linked (derived) class };
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
I guess you mean
c++ Syntax (Toggle Plain Text)
class A { }; class B { A a; };
•
•
Join Date: Mar 2008
Posts: 41
Reputation:
Solved Threads: 7
I think you are thinking about including a file in another file. Write a main function in one file and include the needed header files with that file. Also in each class include the header files they required. The below link will give you a small idea about this.
http://www.eventhelix.com/RealTimeMa...dePatterns.htm
To compile these classes its better to use a Makefile. The following link will guide through how to write and use a Makefile.
http://www.sethi.org/classes/cet375/...mpilation.html
http://www.eventhelix.com/RealTimeMa...dePatterns.htm
To compile these classes its better to use a Makefile. The following link will guide through how to write and use a Makefile.
http://www.sethi.org/classes/cet375/...mpilation.html
In theory, if we supplied ∞ answers, the right one would be among them 
So I'll have a look in my crystal ball and say....: Namespaces!

So I'll have a look in my crystal ball and say....: Namespaces!
cpp Syntax (Toggle Plain Text)
#include <iostream> namespace ClassSpace { class a { public: a() { std::cout << "Created A\n";} ~a(){ } }; class b { public: b(){ std::cout << "Created B\n";} ~b(){} }; } int main() { ClassSpace::a Ca; ClassSpace::b Cb; std::cin.get(); return 0; }
Last edited by niek_e; May 20th, 2008 at 4:27 am.
![]() |
Other Threads in the C++ Forum
- Previous Thread: Need help with Connect 4
- Next Thread: Save file
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets




Can you explain me how to link classes with each other? 

