LinuxQuestions.org
Visit Jeremy's Blog.
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 08-05-2002, 05:33 PM   #1
Ilswyn
LQ Newbie
 
Registered: Aug 2002
Distribution: Debian
Posts: 4

Rep: Reputation: 0
Question C++ Class inheritance problem


Woo, I am glad I found this forum, I am having some problems with class inheritance. I am completely confused why public items are inaccessible in the following highly compressed example , help would be greatly appreciated.

class BaseTest
{
public:
int t1;
};

class Derived1 : BaseTest
{
public:
int t2;
};


main()
{
Derived1* thetest = new Derived1;

thetest->t1 = 101;
thetest->t2 = 102;
};

Errors from gcc:
test.cpp: In function `int main()':
test.cpp:8: `int BaseTest::t1' is inaccessible
test.cpp:22: within this context

Last edited by Ilswyn; 08-05-2002 at 05:43 PM.
 
Old 08-05-2002, 06:24 PM   #2
Ilswyn
LQ Newbie
 
Registered: Aug 2002
Distribution: Debian
Posts: 4

Original Poster
Rep: Reputation: 0
Nevermind, I got it.. Forgot to put public when defining the derived classes.
 
  


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
Implementing a vector class from a list class purefan Programming 9 04-14-2005 10:48 PM
BlackBox.class & VerifierBug.class virus ??? dalek Linux - Security 4 02-29-2004 08:55 AM
Inheriting class members (Qt C++, QApplication class) jtshaw Programming 2 01-15-2004 11:52 AM
c++ : regarding (inheritence)base class and derived class edreddy Programming 6 07-31-2002 06:33 PM
umask...inheritance of file attributes problem iam3 Linux - General 0 11-11-2001 08:44 AM

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

All times are GMT -5. The time now is 10:05 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