•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 426,503 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,231 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 530 | Replies: 11
![]() |
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,184
Reputation:
Rep Power: 38
Solved Threads: 930
You could use a std::vector, or std::list, or write your own linked list. If that isn't what you want then we have no idea what you mean.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
Join Date: Dec 2006
Location: india
Posts: 1,074
Reputation:
Rep Power: 9
Solved Threads: 161
> 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 > ) ) ; }
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,184
Reputation:
Rep Power: 38
Solved Threads: 930
•
•
•
•
There are many classes which must be link or in other words put together in order to work as one big class.
Oh, do you mean inheritence?
class base
{
// blabla
};
class derived : public base
{
// linked (derived) class
};
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
Join Date: May 2006
Location: ★ ijug.net ★
Posts: 939
Reputation:
Rep Power: 5
Solved Threads: 67
I guess you mean
c++ Syntax (Toggle Plain Text)
class A { }; class B { A a; };
•
•
Join Date: Mar 2008
Location: India, Kerala
Posts: 36
Reputation:
Rep Power: 1
Solved Threads: 6
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
•
•
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,779
Reputation:
Rep Power: 11
Solved Threads: 185
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!
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 3:27 am.
Want better/more replies to your questions? Wrap your code in [code] [/code] tags!
do NOT pm me for help, in the best case, you'll get ignored
do NOT pm me for help, in the best case, you'll get ignored
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
apple computer engine france gartner google internet job laptop leopard library linux macbook microsoft mobile new year newb news olympics open operating operating system os parliament programmer search sms source student switching system technology texting torvalds upgrade vista wii wiimote windows xp
- Previous Thread: Need help with Connect 4
- Next Thread: Save file

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

Linear Mode