c++
| lipune (36) | |||
| Hi to all,can u tell me,suppose i have a class in private section i declar a int p,then i derived another class there also i have a private data int p with same name so how can access that data as both in base and derived clas both have same name,,,,,,how can i differentita two data | |||
| bnbertha (404) | |||
First thing to do is change one of the names. If you can't do that then...
Hope this helps | |||
| Duoas (1456) | |||
| The answer is don't do that. (It won't work anyway.) The purpose of private sections is to keep others out.
I think it is worth your time to spend a bit over at the C++FAQ-Lite and read through the sections on inheritance http://www.parashift.com/c++-faq-lite/ Hope this helps. | |||
| maan (9) | |||
| Respected experts please chek my simple code and help me that in this code the division and modulus are not comming correct. #include <iostream.h> main() { //declaring variables// int value1 , value2 , add , subtract , multiply , module , average , square; float divide; //asking the user for values // cout << " Please enter the two numbers" << endl << endl; // Getting values from the user// cout << " Number one please" << endl << endl; cin >> value1; cout << " Number two please " << endl << endl; cin >> value2; //starting operations// divide = value1 / value2; add = value1 + value2; subtract = value1 - value2; multiply = value1 * value2; module = value1 % value2; square = value1 * value1; average = value1 + value2 / 2; //printing output for Addition// cout << "The addition of " <<value1 << "and" <<value2 << " is" << endl << add <<endl; //printing output for Subtraction// cout << "The Subtraction of " <<value1 << "and" <<value2 << " is" << endl << subtract <<endl; //printing output for Multiplication// cout << "The Multiplication of " <<value1 << "and" <<value2 << " is" << endl << multiply <<endl; //printing output for Division// cout << "The Division of " <<value1 << "and" <<value2 << " is" << endl << divide <<endl; //printing output for Modulus// cout << "The Modulus of " <<value1 << "and" <<value2 << " is" << endl << module <<endl; //printing output for Square// cout << "The Square of " <<value1 << "and" <<value2 << " is" << endl << square <<endl; //printing output for Average// cout << "The Average of " <<value1 << "and" <<value2 << " is" << endl << average <<endl; } | |||
This topic is archived - New replies not allowed.
