Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 1st, 2012  |  syntax: None  |  size: 0.44 KB  |  hits: 4  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. C   typedef and return types: how to get the compiler to recognize the return type created with typedef?
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. class A {
  6.     typedef int myInt;
  7.     int k;
  8. public:
  9.     A(int i) : k(i) {}
  10.     myInt getK();
  11. };
  12.  
  13. myInt A::getK() { return k; }
  14.  
  15. int main (int argc, char * const argv[]) {
  16.     A a(5);
  17.     cout << a.getK() << endl;
  18.     return 0;
  19. }
  20.        
  21. myInt A::getK() { return k; }
  22.        
  23. A::myInt A::getK() { return k; }