few queries on classes and objects

Discussion in 'Programmer's Corner' started by PG1995, Sep 30, 2011.

  1. PG1995

    Thread Starter Well-Known Member

    Apr 15, 2011

    The queries are about classes and objects in C++.

    1: Can I say that a class is a kind of global variable? Can I define a class within the main()?

    2: Suppose inputFunc() is a public function of class A and variable Var is a data member of that class. When a call inside the main() is made:

    Code ( (Unknown Language)):
    1. Var.inputFunc();
    I think it can be said the call to inputFunc() has been made by the variable Var to be operated upon. Does it make sense?

    3: I also believe that ISO C++ doesn't allow initialization of data members inside the class. Is that really so?

    Please help me with the queries above. Thanks.
    Last edited: Oct 1, 2011