Hello, Roger,
Fixed.
The virtual
keyword only means that the function’s behavior may change depending on the object’s class. It doesn’t have to do with the returned data type, which is char *
. Suppose the Animal
class that has a virtual string talk(){return "";}
. You can have a Dog
and a Cat
classes that extend Animal
. These subclasses may override Animal::talk()
to implement behavior especific to them: virtual string Dog::talk(){ return "woof woof!";}
and virtual string Cat::talk(){ return "meow!";}
. So if you declare an Animal
object like this: Animal* a = new Dog();
and if you call its talk()
method, it’ll return “woof woof!”. Without the virtual
keyword, it would return an empty string, since a
belongs to the Animal
class. The virtual
keyword is one way in C++ to implement polymorphism, that is, variable behavior for seemingly the same thing.
char
means a single character. *
means that it is a pointer to the given data type. So char *
is a variable that has the memory address to a singe character. Normally, a char *
denotes the pointer to the first character of a string, which ends with the first of the following characters that has the null character (\0
) or the 8-bit integer value of zero. These are the so-called "C-string"s. In practice, C++ programmers use some high level string class such as std::string
. You can just create a std::string
object from a char *
by doing, for example, std::string myString( shaderProperty->GetFragmentShaderCode() );
.
Please, take a look at some examples of shader usage here: Any example or tips to render sea surface(shader+FFT)? - #2 by Paulo_Carvalho .
take care,
Paulo