|
Hi,
I am learning C++, but I am confused about abstract class and concrete class. Some real world examples would be appreciated.
Started by coming out of void on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
A concrete class is a class an abstract....
An abstract class serves class (deriving from Car ) class is a concrete implementation.
An abstract class can't be instantiated whilst a concrete one can.
|
|
In an OO component, when you have only one implementation available for an class and that class is not 'published' to other components, is it still advisable to have an interface and work with the interface instead?
I am fully aware of 'programming to...
Answer Snippets (Read the full thread at stackoverflow):
Interfaces shouldCreating interfaces for....
The alternative to that would be to not use the interface and subclass the concrete class, which works too, but again it depends.
With the interface as opposed to the concrete class.
|
|
How would design and organize tests for the concrete methods of an abstract class? Specifically in .NET.
Started by Russell Myers on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
I Always use Stub/Mock object
You have to define and create a concrete test class that inhereits to create a subclass that....
You have.
The first thing that comes to mind is to test those methods in a concrete child class.
|
Ask your Facebook Friends
|
Are there some practical programming situations for someone to declare a class abstract when all the methods in it are concrete?
Started by sarav on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
To facilitate implementation of your concrete classes you might want to provide an abstract class providing default behavior....
They cannot be instantiated so if you have an abstract class with concrete methods then it can.
|
|
Background
I have an abstract class, something like
class IConverter{ public: virtual void DoConvertion() = 0; };
There will be many concrete classes which just implements DoConvertion method.
class TextConverter : public IConverter{ public: virtual void...
Started by Appu on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
It is not required.
In the header file, and have all the concrete class definitions and implementations in a single .cpp declarations defeats this, so now if you change an implementation detail of a concrete class, your.
|
|
I have class with a forwarding method foo:
void foo( Concrete c, String s ) { c.bar( s ); }
I wish to test that foo in fact forwards. Unfortunately for me, Concrete is a class in a third-party library, and is a Concrete type, not an interface. Thus I ...
Started by tpdi on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
If your use of Concrete is simple enough, I would consider wrapping Concrete); }....
For Concrete like this:
public class ConcreteStub extends Concrete { public int numCallsToBar = 0 of the Concrete class.
|
|
I want to avoid calling a lot of isinstance() functions, so I'm looking for a way to get the concrete class' name for an instance variable as a string.
Any ideas?
Answer Snippets (Read the full thread at stackoverflow):
Instance.__class__.__name__
example:
>>> class A(): pass >>> a = A() >>> a.__class__.__name__ 'A'
<object>.__class__.__name__
you can also create a dict.
|
|
Guideline #4 link text , states:
A base class destructor should be either public and virtual, or protected and nonvirtual.
Probably I'm missing something, but what if I just create a concrete class, that is not designed to be used as base class.
Should...
Answer Snippets (Read the full thread at stackoverflow):
For a concrete class that won't be used as a base class....
If you are making a single, concrete class that will not be used as a base class, you should calling delete on a base class pointer.
class.
|
|
Mocking a concrete class with Rhino Mocks seems to work pretty easy when you have an empty constructor on a class:
public class MyClass{ public MyClass() {} }
But if I add a constructor that takes parameters and remove the one that doesn't take parameters...
Started by Mark Rogers on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
MockRepository mocks = new MockRepository(); FruitBasket basket = mocks.CreateMock<FruitBasket>(50);
You have to pass them in after your DynamicMock... .
Just pass in the parameters in your CreateMock() call:
// New FruitBasket that can hold 50 fruits .
|
|
Hello guys,
I am in a tough spot and I cannot figure it out. I am using legacy code and we are migrating from PicoContainer 1.1 to Spring 2.5. I came across code where Pico grabs the abstract class and is able to invoke concrete methods. How can I do ...
Started by Thomas on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The simple thing to do is:
class the class....
Be a concrete class somewhere that extends AbstractClass and implements the abstract methods; even if that concrete class is built by PicoContainer behind the scenes.
|