×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Hi!!!!,I’m a new in the world of pr

Hi!!!!,I’m a new in the world of pr

Hi!!!!,I’m a new in the world of pr

(OP)
Hi!!!!,I’m a new in the world of programming(C++)…I want to know about..what the meaning and the function of :-

Class base{

1)Private
2)public:
    void getdata();
    void display();

3)class derivedB:public base and what the different with
    symbol ::
4)and the meaning in void main()
{
base*ptr;
derivedB object;
ptr=&object;
ptr->getdata();
ptr->display();
getch();

This is my program:-


#include<iostream.h>
#include<conio.h>



class base{
private:

int x;
int y;



public:
void getdata();
void display();


};

class derivedB:public base{

private:
int rollno;
char name[20];


public:
void getdata();
void displaydata();

};

void base::getdata()

{

cout<<

RE: Hi!!!!,I’m a new in the world of pr

Hi Visitor

ok

there are 3 categories of access to a class
1 public the data members and functions can be accessed by any external part of the program

2 private these members can only be accessed by member functions of the class (also other class member functions that have been declared as "friend" classes of functions

3 protected used for inheritence


2)public:
    void getdata();
    void display();

this means that the member functions can be called by external non member function within your code


3 :: is the scope resolution operator in other words if you have a derived class and a base class with the same function names this allows you to specify which class function you are calling base or derived

4
base*ptr;  // pointer to base class
derivedB object; // an instance of a derivedb object
ptr=&object; // reassiging ptr tp point to the instance   
             //object
ptr->getdata(); // now calls derived member function
ptr->display(); // again calls derived member function
getch();        // ugly not a c++ method use istream but
                // you need to learn more first


void base::getdata() // scope resolution you intend to call the base class member function...

hang in it will become clear, join the forum and enjoy

HTH
Robert


RE: Hi!!!!,I’m a new in the world of pr

(OP)
Thank u very much for your explanation!!!! Robertd...i hope u can guide me to be agood programming again..and i hope we can be a member for the fortune

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close