C ++: Ist es möglich, eine Mitgliedsfunktion zu erweitern?C++

Programme in C++. Entwicklerforum
Anonymous
 C ++: Ist es möglich, eine Mitgliedsfunktion zu erweitern?

Post by Anonymous »

Ich bin relativ neu in C ++ und möchte wissen, ob es möglich ist, Folgendes zu tun, und wenn ja, gibt es eine bessere Möglichkeit, das gleiche oder ähnliche Ergebnis effizienter zu erzielen? instance of the struct/class
Or
[*]B Add to the function definition of the struct/class

Edit: The following is not necessarily valid C++ and should be read as psudo-code

Code: Select all

struct MyStruct {
public:
void MyFunction () {
// Content A
}
}
< /code>
A: < /p>
MyStruct a;
a::MyFunction() {
// Content B
}
wobei a.myfunction () ausgeführt würde:

Code: Select all

MyFunction () {
// Content A

// Content B
}
< /code>
b: < /p>
MyStruct::MyFunction () {
// Content B
}

MyStruct b;
wobei b.myfunction () ausgeführt würde wie:

Code: Select all

MyFunction () {
// Content A

// Content B
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post