C++ Method chaining on constructor
I'm trying allow for method chaining on the Constructor and I have ran
into the same problem on this C++ method chaining including class
constructor and I have tried the suggested answers but still getting the
same error. My code is below:
class Signal {
public:
Signal() { }
Signal& Emphasize() {
return *this;
}
};
enum ReadType { NATIVE = 0, DOUBLE, };
class Wav : public Signal {
public:
Wav(string fileName, ReadType type) {
}
};
I have tried calling from the following:
Wav* wave = new Wav("asf", DOUBLE).Emphasize();
And:
Wav wave = Wav("asf", DOUBLE).Emphasize();
I don't know whether the actual process is possible since "Emphasize" it's
not a constructor but hopefully I will be allowed to access it. What could
I be doing wrong here for this not to work?
Hope someone can help :)
UPDATE:
I put "Emphasize()" as a class member inside "Wav" and it worked, how I
wanted. BUT does anyone know of a way I can access this member inside
"Signal" without having to place the class member inside of "Wav"?
No comments:
Post a Comment