CrazyEngineers
  • Need help in c++.

    BCA_GIRL

    BCA_GIRL

    @bca-girl-wzX9cA
    Updated: Oct 23, 2024
    Views: 916
    Hi,
    I have completed C last year and now starting studing C++. Can anyone help me please..😕
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Manish Goyal

    MemberAug 5, 2010

    How can we help?
    Are you sure? This action cannot be undone.
    Cancel
  • Pensu

    MemberAug 5, 2010

    What kind of help exactly do you want?.......specify...
    Are you sure? This action cannot be undone.
    Cancel
  • BCA_GIRL

    MemberAug 6, 2010

    Hi,
    I am confused about "classes in C++". Please provide me notes of this topic or expain it to me. In wait of your reply..........
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberAug 6, 2010

    Classes are soul of oops
    its a large topic no one can explain in single post
    please explain where are you getting confused?
    Are you sure? This action cannot be undone.
    Cancel
  • BCA_GIRL

    MemberAug 6, 2010

    I need a program that illustrates "structure and classes".
    Are you sure? This action cannot be undone.
    Cancel
  • Pensu

    MemberAug 6, 2010

    Check the following link. It may help you.

    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • sushant005

    MemberAug 6, 2010

    Let me explain you what is class?

    In the simple sense we can say that class is a logical concept.It means that it has no existence without an object.
    Now what is a object?
    Object is physical concept or we can say that it is the instance of class or we can say that object has a state and behavior.

    As class is logical concept it does not allocate any memory unless an object is created.
    Class is same as the structure or you can say that it is the next step to the structure and build with some extra features than structure.

    struct book
    {
    char name;
    float price;
    char author;
    }b;
    If you consider the above program here structure are no going to take memory.It is just a form of structure data type struct book unless you do not create any structure variable i.e b it does not take any memory space.Like wise in class concept when we are create/ declare object then only it takes the memory space for the data members defined within the class.

    The major difference between the structure and the class is that Structure is by default public and class is by default private.

    You will better understand class with the concept of OBJECT.

    If you have any doubt feel free to ask any question regarding this!
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberAug 6, 2010

    Nice explanation sushant,
    one more difference to add
    In case of classes data hiding is possible where as in case of structures data hiding is not possible which is one of the drawback of structureS

    Here data hiding means "The object know only about data that it needs to know"
    Are you sure? This action cannot be undone.
    Cancel
  • sushant005

    MemberAug 7, 2010

    One more difference and i think this difference clear idea about the class and the structure.

    Class is logical concept where as structure is a physical concept.

    Here is the program clears the idea about structure,

    #include<iostream.h>
    struct node
    {
    int a;
    };
    void main()
    {
    cout<<"output="<<sizeof (struct node);
    }
    Here in the above program the struct is defined outside the main().And one thing to notice is that there is no struct variable declared but it shows the size of the struct node.It proves that it is a physical concept since without declaring the structure variable it take memory space.But that is not in the case of class is totally logical unless we create an object it is no going to take any memory space.

    here the code for the class,
    #include<iostream.h>
    #include<conio.h>
    class A
    {
    public:
    int a;
    };
    void main()
    {
    A a;/*here object is created and this allows to take the memory space for the class variable.
    unless you create object class has no existence*/
    cout<<"Size of A="<<sizeof (a);
    getch();
    }
    Are you sure? This action cannot be undone.
    Cancel
  • Morningdot Hablu

    MemberAug 7, 2010

    Nice explanation sus.
    Looks like you also gonne cody now.
    Are you sure? This action cannot be undone.
    Cancel
  • PraveenKumar Purushothaman

    MemberMay 17, 2011

    A simple explanation would be this way... Hope so... 😀
    [​IMG]
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register