What are the various access specifiers in c++?



What are the various access specifiers in c++?..

Answer / Seema Pal

In C++, there are three access specifiers: private (denoted by 'private:' or just 'private'), protected (denoted by 'protected' or 'protected:'), and public (denoted by 'public').nn1) Private: Variables and functions marked as private can only be accessed within the class.n2) Protected: Variables and functions marked as protected can be accessed by the member functions of the class, its derived classes, and friend classes.n3) Public: Variables and functions marked as public can be accessed from anywhere in the program.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What does return 0 do in c++?

1 Answers  


Is multimap sorted c++?

1 Answers  


Write a program to concatenate two strings.

1 Answers  


What is a mutex and a critical section.Whats difference between them?How do each of them work?

4 Answers   CTS,


What is a forward referencing and when should it be used?

1 Answers  


What is the use of register keyword with the variables?

1 Answers  


what is COPY CONSTRUCTOR and what is it used for?

1 Answers  


can any one help to find a specific string between html tags which is changed to a sting.. weather.html looks (for location) is <location>somewhere</location> #include <iostream> #include <fstream> #include <string> using namespace std; string find_field(string myPage,string); int main (void) { string page, line, location, temperature; ifstream inputFile("weather.xml"); while(getline(inputFile, line)) { page.append(line); line.erase(); } // Now page is a string that contains the whole xml page // Here you need to write something that finds and // extracts location and temperature from the XML // data in the string page and stores them in // the strings location and temperature respectively location=find_field(page,"location"); temperature=find_field(page,"temp_c"); cout << "Location: "<<location << endl; cout << "Temperature: " << temperature << endl; system("pause"); } string find_field(string myPage,string find_string){ int temp=myPage.find(find_string); if(temp!=string::npos) { cout << "Match found at " << temp << endl; } return "found?"; } ///

1 Answers  


What is the best way to declare and define global variables?

1 Answers  


What are the basics concepts of OOPS?

1 Answers  


What is a constructor and how is it called?

1 Answers  


What is the correct syntax for inheritance a) class aclass : public superclass b) class aclass inherit superclass c) class aclass <-superclass

1 Answers  


Categories