Re: How to add a class to the tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Aug 1, 2009, at 5:11 AM, Klesk wrote:

Let's say I have code like this:

SampleClass object;

which of course fails to compile because there is no SampleClass.

How to programmically create a class named SampleClass to make it
possible to complie ?


-- Klesk


Hi, Kiesk!

#include <iostream>

class SampleClass {
 private:
   int id;
 public:
  SampleClass() {
   id = 42;
 }
 int get_id() {
   return id;
 }
};

int main(int argc, char ** argv) {

 SampleClass object;
 std::cout << object.get_id() << std::endl;
 return EXIT_SUCCESS;
}


Do you mean something else? By "programmatically create," do you mean create dynamically at runtime, as you would using the reflection mechanisms of Java or C#?

Thanks.


Amittai Aviram
Graduate Student in Computer Science
Yale University
646 483 2639
amittai.aviram@xxxxxxxx
http://www.amittai.com


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux