Assignment 2 (Release 0.3): Q & A

From CDOT Wiki
Revision as of 18:01, 11 November 2012 by Shajinth Pathmakulaseelan (talk | contribs) (Q & A)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Q & A

Q: How to initialize constant data member variables of class ?
A: As we know constant things in c++ can only be initialized.They cannot be assigned later. Also in c++ during class declaration we cannot initialize things.so the only way in which we can initialize constant data members of class is by using initialization list.following piece of code will explain it clearly:
#include <iostream>
using namespace std;

class test {

 private:
   const int i;
 public:
     test(int f):i(f)
     {
        
        cout<<"i = "<<i<<endl;
     }     

};
int main() {

  const int k =9;
  test t(k);
  return 0;  

}
Submitted by: Shajinth Pathmakulaseelan and Auquib Rasul, Team 2

Q: What is the use of this pointer?
A: this pointer is passed as an implicit argument to member function of class. This pointer contains the address of invoking object i.e the object on which member function is called.this pointer is very useful during operator overloading.
Submitted by: Shajinth Pathmakulaseelan and Auquib Rasul, Team 2

Bug Reports

Possible/Challenging Enhancements

Features Proposed by Team 42

  1. Smart word wrapping - words are not cut off mid-word while wrapping
  2. Optimization - "test" compiled executables have efficiency issues when moving boxes around
  3. Colors - you can add color to the test program if you're making your own main
  4. Timer - to keep track of how long the user has been running your custom main
  5. Files - Read string from file, use that string for editing, then write the result string to that file, overwriting original