English
Tamil Nadu Board of Secondary EducationHSC Science Class 11

Differentiate structure and class though both are user-defined data types. - Computer Science

Advertisements
Advertisements

Question

Differentiate structure and class though both are user-defined data types.

Distinguish Between

Solution

The only difference between structure and class is the members of the structure are by default public whereas it is private in class.

shaalaa.com
Introduction to Classes
  Is there an error in this question or solution?
Chapter 14: Classes and objects - Evaluation - Section - B [Page 247]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 11 TN Board
Chapter 14 Classes and objects
Evaluation - Section - B | Q 2. | Page 247

RELATED QUESTIONS

What are called members?


What is the difference between the class and object in terms of oop?


Why it is considered good practice to define a constructor though a compiler can automatically generate a constructor?


The variables declared inside the class are known as ______.


Which of the following statements about member functions are True or False?

i) A member function can call another member function directly by using the dot operator.

ii) Member function can access the private data of the class.


A member function can call another member function directly, without using the dot operator called as ______


Which of the following access specifier protects data from inadvertent modifications?


Rewrite the following program after removing the syntax errors if any and underline the errors:

#include<iostream>
$include<stdio>
class mystud
{ int studid =1001;
char name[20];
public
mystud( ) { }
void register ( )
{cin>>stdid; gets(name); }
void display ( )
{cout<<studid<<”: “<<name<<endl;}
}
int main( ) { mystud MS; register.MS( ); MS.display( ); }
int main( )
{ mystud MS;
register.MS( );
MS.display( );
}


Define a class RESORT with the following description in C++ :

Private members:
Rno // Data member to storeroom number
Name //Data member to store user name
Charges //Data member to store per day charge Days //Data member to store the number of days Compute( )/*A function to calculate a total amount as Days * Charges and if the total amount exceeds 11000 then the total amount is 1.02 * Days *Charges */
Public member:
GetInfo( ) /* Function to Read the information like name , room no, charges and days*/
DispInfo( )/* Function to display all entered details and total amount calculated using COMPUTE function*/


Write the output of the following

#include<iostream>
using namespace std;
class student
{
  int rno, marks;
  public: student(int r, int m)
  {
    cout << "Constructor " << endl;
    rno = r;
    marks = m;
  }
  void printdet()
  {
    marks = marks + 30;
    cout << "Name: Bharathi" << endl;
    cout << "Roll no : "<<rno << "\n";
    cout << "Marks : "<<marks << endl;
  }
};
int main()
{
  student s(14,70);
  s.printdet();
  cout << "Back to Main";
  return 0;
}

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×
Our website is made possible by ad-free subscriptions or displaying online advertisements to our visitors.
If you don't like ads you can support us by buying an ad-free subscription or please consider supporting us by disabling your ad blocker. Thank you.