URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 227 |
Rev 816 |
|
|
class Base
|
class Base
|
{
|
{
|
public:
|
public:
|
virtual int get_foo () { return 1; }
|
virtual int get_foo () { return 1; }
|
int base_function_only () { return 2; }
|
int base_function_only () { return 2; }
|
};
|
};
|
|
|
class Foo : public Base
|
class Foo : public Base
|
{
|
{
|
|
|
private:
|
private:
|
int foo_value;
|
int foo_value;
|
|
|
public:
|
public:
|
Foo () { foo_value = 0;}
|
Foo () { foo_value = 0;}
|
Foo (int i) { foo_value = i;}
|
Foo (int i) { foo_value = i;}
|
~Foo () { }
|
~Foo () { }
|
void set_foo (int value);
|
void set_foo (int value);
|
int get_foo ();
|
int get_foo ();
|
|
|
// Something similar to a constructor name.
|
// Something similar to a constructor name.
|
void Foofoo ();
|
void Foofoo ();
|
|
|
bool operator== (const Foo &other) { return foo_value == other.foo_value; }
|
bool operator== (const Foo &other) { return foo_value == other.foo_value; }
|
};
|
};
|
|
|
void Foo::set_foo (int value)
|
void Foo::set_foo (int value)
|
{
|
{
|
foo_value = value;
|
foo_value = value;
|
}
|
}
|
|
|
int Foo::get_foo ()
|
int Foo::get_foo ()
|
{
|
{
|
return foo_value;
|
return foo_value;
|
}
|
}
|
|
|
void Foo::Foofoo ()
|
void Foo::Foofoo ()
|
{
|
{
|
}
|
}
|
|
|
int main ()
|
int main ()
|
{
|
{
|
// Anonymous struct with method.
|
// Anonymous struct with method.
|
struct {
|
struct {
|
int get() { return 5; }
|
int get() { return 5; }
|
} a;
|
} a;
|
Foo foo1;
|
Foo foo1;
|
foo1.set_foo (42); // Set breakpoint here.
|
foo1.set_foo (42); // Set breakpoint here.
|
a.get(); // Prevent compiler from throwing 'a' away.
|
a.get(); // Prevent compiler from throwing 'a' away.
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.