What is the difference between Class and Structure?

Answers were Sorted based on User's Feedback



What is the difference between Class and Structure?..

Answer / ravi kumar jain

The difference between a class and a structure is that, by
default, all of the members of a class are private and, by
default, all of the members of a structure are public.The
difference between a class and a structure is that, by
default, all of the members of a class are private and, by
default, all of the members of a structure are public.

Is This Answer Correct ?    0 Yes 2 No

What is the difference between Class and Structure?..

Answer / sharad

in c++ structure and class are same. we can use the
structure in place of class for creating the object. but
the difference is only the default access specifier of the
class is private and public of the structure.

Is This Answer Correct ?    0 Yes 2 No

What is the difference between Class and Structure?..

Answer / deepica

in classes we can declare variables and functions while in structure we can have only functions.In classes we have ACCESS SPECIFIER,while in structures we dont have any.Ic classes no Keyword is used ,while in Structures STRUCT keyword is used.

Is This Answer Correct ?    0 Yes 2 No

What is the difference between Class and Structure?..

Answer / nikhil jain

Structures are value types; classes are reference types.
Structures use stack allocation; classes use heap
allocation.

A structure must have at least one nonshared variable or
event member; a
class can be completely empty.

Is This Answer Correct ?    4 Yes 9 No

What is the difference between Class and Structure?..

Answer / hardik savani

The Structure ara used in c and c++
but class is used only in c++ and other opps languages

Is This Answer Correct ?    23 Yes 33 No

What is the difference between Class and Structure?..

Answer / anupam gupta

class has define object and funtion
structure has define only object

Is This Answer Correct ?    8 Yes 18 No

What is the difference between Class and Structure?..

Answer / shiva

we create an object for class.but not creating for structure

Is This Answer Correct ?    3 Yes 19 No

What is the difference between Class and Structure?..

Answer / arun

a structure is nothing but a structure.a class is nothing
but a class

Is This Answer Correct ?    2 Yes 26 No

What is the difference between Class and Structure?..

Answer / mm .mm

class can be used in other project ... but stucture can not
be used it's only present in the main

Is This Answer Correct ?    20 Yes 48 No

What is the difference between Class and Structure?..

Answer / rafat-+8801671123467

class is class and structure is structure.

Is This Answer Correct ?    6 Yes 36 No

Post New Answer

More C++ General Interview Questions

What are the operators in c++?

0 Answers  


class Foo { public: Foo(int i) { } }; class Bar : virtual Foo { public: Bar() { } }; Bar b; Referring to the above code, when the object 'b' is defined, a compiler error will occur. What action fixes the compiler error? a) Adding a virtual destructor to the class Bar b) Adding a constructor to Bar which takes an int parameter c) Adding "Foo()" to the Bar constructor d) Adding a copy constructor to the class Foo e) Adding "Foo(0)" to the Bar::Bar initializer list

2 Answers   Quark,


Explain about profiling?

1 Answers  


What are advantages of c++?

0 Answers  


how to swap two numbers with out using temp variable

12 Answers   Global eProcure, TCS,






how can i access a direct (absolute, not the offset) memory address? here is what i tried: wrote a program that ask's for an address from the user, creates a FAR pointer to that adress and shows it. then the user can increment/decrement the value in that address by pressing p(inc+) and m(dec-). NOW, i compiled that program and opened it twice (in 2 different windows) and gave twice the same address to it. now look what happen - if i change the value in one "window" of the program, it DOES NOT change in the other! even if they point to the same address in the memory! here is the code snippet: //------------------------------------------------------ #include <stdio.h> //INCLUDE EVERY KNOWN HEADER FILE #include <conio.h> //FOR ANY CASE... #include <iostream.h> #include <dos.h> #include <process.h> main() { int far *ptr; //FAR POINTER!!! long address; char key=0; //A KEY FROM THE KEYBOARD int temp=0; clrscr(); cout<<"Enter Address:"; cin>>hex>>address; //GETS THE ADDRESS clrscr(); (long)ptr=address; temp=*ptr; //PUTS THE ADDRESS IN THE PTR cout<<"["<<hex<<(unsigned long)ptr<<"]="<<*ptr<<" = "<< (char)(*ptr); //SHOWS: [address]=value=ASCII symbol. while (key!=27) //WHILE YOU DONT PRESS ESC. { while(!kbhit()) //WHILE KEY IS NOT PRESSED { if (temp!=*ptr) { temp=*ptr; clrscr(); cout<<"["<<hex<< (unsigned long)ptr<<"]="<<*ptr<<" = "<<(char)(*ptr); }; //IF THE VALUE HAS CHANGED, CLEAR THE SCREEN AND SHOW //AGAIN if (key=='p') {key=0; (*ptr)++; } //INCREMENT VALUE if (key=='m') {key=0; (*ptr)--; } //DEC. VALUE }; key=getch(); //IF A KEY IS PRESSED, READ IT FROM THE //KEYBOARD }; return 0; //IF ESC WAS THE KEY, EXIT THE PROGRAM } //---------------------------------------------------------

0 Answers  


Any one help me plzzzz..... i have an assignment...... that is ______*********_______ Write a program that takes an equation as a string and does the following: Solve 8 parts to achieve 100% 1 - 5 are compulsory. Input: 2x^2+3x+4=0 1) read a quadratic equation 2) print its coefficients (coefficients range is 0 to 9) 3) print the solution of the equation 4) tackle imaginary solution e.g. ( (2+3i), (2-3i) ) 5) allow spaces within the input 6) after solving one equation; ask for an other, terminate on empty line. * 7) tackle negative values as well * 8) tackle more than one values of same exponent (e.g. 2x^2 + 3x^2 + 4x + 3 = 0)* 9) use strtok * 10) print the solution in fractions e.g. 1.5 should be printed as (1)1/2 * 11) coefficient can be greater than 9** 12) values on both sides of the ‘=’ sign** 13) plot the graph of the polynomial** 14) use a compiler other than Borland** 15) submit before May 25, 2009 11:59 PM ** _______******________ plz send me c++ code at sweety.alvi@gmail.com

1 Answers  


Which is the best c++ software?

0 Answers  


What is c++ hiding?

0 Answers  


What is the difference between public, private, protected inheritance?

12 Answers   Wipro,


What is the need of a destructor? Explain with the help of an example.

0 Answers  


What is the difference between operator new and the new operator?

3 Answers   Amazon, TCS, Wipro,


Categories