LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-02-2012, 01:46 AM   #16
ofer4
Member
 
Registered: Apr 2012
Posts: 100

Original Poster
Rep: Reputation: Disabled

Quote:
Originally Posted by johnsfine View Post
The basics of what you should do are shown here:
Code:
class Mat
{
public:
    Mat(int rows, int Cols);
};


class teacher
{
    Mat m_mat1;
    Mat m_mat2;
public:
    teacher( int r1, int c1, int r2, int c2 ) :
        m_mat1(r1, c1),
        m_mat1(r2, c2)
    {}
};
The two Mat objects are members of teacher rather than base classes.

In post #7, I showed a way to make Mat be a base class of teacher twice (by disguising Mat with a numbered template wrapper struct). If there were some good reason to want Mat as two base classes of teacher rather than as two members, then this shows you it is possible. If you try to work with the starting point from post #7, you could make it work, but I don't think any aspect of that would have advantages vs. the simpler approach shown in this post.


thanks alot

i have one more question

if for mat2 i want to create a new methods (dont want to use the inherited methods)

and for mat1 i want to use the inherited methods.

how can i implement it?

thanks
 
Old 06-02-2012, 02:30 AM   #17
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
Quote:
Originally Posted by ofer4 View Post
thanks alot

i have one more question

if for mat2 i want to create a new methods (dont want to use the inherited methods)

and for mat1 i want to use the inherited methods.

how can i implement it?

thanks
I think you still haven't got it... There's no inheritance in the code snippet you quoted and you can't create new operations/methods only for a specific instance (mat2) without affecting the Mat class definition (therefore, all instances will be affected).
You should really try to better explain what you'd want to achieve so we can help you better.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 07:24 AM
linux distro question & mysql install question natalie.aloi Linux - Newbie 5 07-19-2009 08:28 PM
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration