I am currently studying the LLVM IR. I understand that llvm::Value is an important class in LLVM, and llvm::Value has many derived classes such as llvm::Function, llvm::BasicBlock and llvm::Instruction, etc. One thing that baffles me is the llvm::Constant class. It has the following derived classes:
llvm::BlockAddress
llvm::ConstantAggregate
llvm::ConstantData
llvm::ConstantExpr
llvm::DSOLocalEquivalent
llvm::GlobalValue
llvm::NoCFIValue
Here are my questions:
What are the meanings of the above classes? Do they have the corresponding source code entities?
With regard to the subclasses of llvm::GlobalValue, what does llvm::GlobalAlias mean? What is the difference between llvm::Function and llvm::GlobalIFunc?
Could someone give me any ideas, or where can I find the detailed documentation to answer the above questions?
Related
In object oriented programming class the instructor is telling that
Inheritance is called Object code level reuse.
But I was thinking how because We don't have the source code is not available in object or any other compiled library file so how can we inherit a function or class for reuse if We don't have the source code.
Normally we inherit a class whose source code or class information is available.
Can somebody explain it?
The other question need the explanation is :
how container-ship is different than inheritance?
Because I read that container-ship is a derive which has a relation-ship from base class as "has a relation", which I feel is inheritance only.
Any explanation is appreciated.
Thanks.
I know there are a few different ways to achieve polymorphism in c++.
I know of 3 ways to do this:
by using inheritance (through the use of a pointer to a base class)
by using virtual function
by using abstract classes
During a technical discussion on the topic I was told I am missing something and was left hanging...hence I asked the question here.
Is there another way in c++ to to this or is something I said wrong?
Your three ways are really just one: whether the base class is
abstract is an implementation detail; you need virtual
functions, which can be overridden in a derived class.
Other than that: both function overloading and templates provide
a form of polymorphism as well, although it is resolved at
compile time, and not run time. For that matter, you can define
a class in a header file, and provide several different
implementations for it, depending on compile time switches;
that's also a form of polymorphism. (This is often done for
system dependent code. The polymorphism is resolved as
a function of the system you're compiling for.)
I think your discussion was related to different types of polymorphism.
Compile time polymorphism - Ex: Function Overloading, Operator Overloading.
Run time polymorphism - Ex: Inheritance + virtual functions + base class pointer.
For a project, I am being asked to create a VST using the Steinberg SDK, i'm using version 2.4.
The issue that I'm having is error:
cannot allocate an object of abstract type 'mySynth'.
When attempting to compile, the error brings me to this section of code:
AudioEffect* createEffectInstance (audioMasterCallback audioMaster)
{
return new mySynth (audioMaster);
}
I'm a beginner to both c++ and VST programming, I've had no issues compiling the sample AGain and ADelay, as well as the vstxSynth. This is the first attempt of my own, and its really confusing me, from looking at the sample code i cannot seem to find any reason as to why this shouldn't work.
any help would be greatly appreciated. As this is a major learning curve for me, i would appreciate if you could apply with a simplest explanations as possible.
Thankyou :)
Without seeing the class mySynth code it is hard to say but this error is commonly encountered when you have a class containing a pure virtual function. Either that or you have derived from a base class with a pure virtual function and have failed to override it with a derived class implementation.
If you do not know what that means, look in your class (and sub classes) for functions declared like this
virtual int my_function() = 0;
This kind of function is a pure virtual function and a class that has one is considered an abstract class and cannot be instantiated. In order to do so you would need to provide an implementation.
Your processReplacing() method is not correctly overriding signature declared in the base class AudioEffect. The signature looks like this:
void processReplacing(float** inputs, float** outputs, VstInt32 sampleFrames);
Your override is using double, it should use float instead.
This question already has answers here:
Closed 12 years ago.
Possible Duplicates:
C++ Virtual/Pure Virtual Explained
What's the difference between virtual function instantiations in c++
Why pure virtual function is initialized by 0?
This is a method in some class declaration that someone gave me. And I don't know what '..=0' means. What is it?
virtual void Print() const = 0;
The = 0 makes the function pure virtual, rendering the class an abstract class.
An abstract class basically is a kind of interface, which derived classes need to implement in order to be instantiable. However, there's much more to this, and it is some of the very basics of object-oriented programming in C++. If you don't know these, you need to go back to the textbook and read up. There's no way you can advance without understanding them.
That said, see this related question for some explanations of what virtual and pure virtual functions are. And as always, the C++ FAQ is an excellent resource for such questions.
It means that the virtual function is pure, meaning that you cannot call it as such: the function doesn't have any code to it, hence the = 0. Only by deriving the class and overriding the function you can call it. The class with pure virtual functions cannot be instantiated so they are called abstract classes, interfaces in some languages.
Basically, it means the function has no code. This means that you cannot use instances of this class. Rather, it can only be a base class.
Can somebody please let me know, what does contingency code mean...??\
I read it in c++ complete ref, and it related it with virtual functions,
that due to late binding, since calls to virtual functions are resolved at run-time, we dont have to write a lot of "contingency code".
But it did not explain what contingency code meant.
Ìn this context, a fancier word for 'code with a lot of if and switch statements', which imperative non-OO code often seems prone to. See contingency.
Contingency means "A provision for such an event or circumstance" according to Google. I think he's referring to the fact that derived classes do not have to implement all of the virtual interface of the base class, if there is a definition for the function in the base class (ie, the function is not pure virtual).
This would reduce the amount of "function provision for such objects."
That's my best guess.