vc++ class need run-time library?
-
- Posts: 21
- Joined: Sun Feb 19, 2012 7:25 am
vc++ class need run-time library?
hi!
mvc++ class need run-time library?
thank!
mvc++ class need run-time library?
thank!
Re: vc++ class need run-time library?
hi!berkus wrote:hi!
class need library sometimes.
pleas
I haz lol'ed.
thank!
-
- Posts: 21
- Joined: Sun Feb 19, 2012 7:25 am
Re: vc++ class need run-time library?
excusme if my question was very bad.
there for in normal condition i didnt need run time library except when use for example pur virtual function.yes it is?
there for in normal condition i didnt need run time library except when use for example pur virtual function.yes it is?
Re: vc++ class need run-time library?
+++ More Cheese Error +++
Insufficient information.
Redo from start.
Insufficient information.
Redo from start.
Every good solution is obvious once you've found it.
- Griwes
- Member
- Posts: 374
- Joined: Sat Jul 30, 2011 10:07 am
- Libera.chat IRC: Griwes
- Location: Wrocław/Racibórz, Poland
- Contact:
Re: vc++ class need run-time library?
You know that pure virtual function can have implementation, don't you? ;Dberkus wrote:1) they are pure and therefore are not implemented
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
Re: vc++ class need run-time library?
I'm not sure which strange programming language you are thinking about, but in C++, a pure virtual function declaration looks like this:Griwes wrote:You know that pure virtual function can have implementation, don't you? ;Dberkus wrote:1) they are pure and therefore are not implemented
Code: Select all
virtual void virtualfunctioname() = 0;
Every good solution is obvious once you've found it.
Re: vc++ class need run-time library?
I think you are wrong here. A pure virtual function can have an implementation, still the class cannot be instantiated, but the function can be called by derived classes.Solar wrote:The "= 0" indicates that this function does not have an implementation, which - at least in C++ - is the definition of "pure virtual". Not only can the function not have an implementation, the whole class cannot be instantiated.Code: Select all
virtual void virtualfunctioname() = 0;
Code: Select all
virtual void func() = 0
{ std::cout << "HELLO WORLD"; }
-
- Posts: 21
- Joined: Sun Feb 19, 2012 7:25 am
Re: vc++ class need run-time library?
can you give me book or some resource aboute this?berkus wrote: Are you trying to approach C++ programming without actually understanding what C++ is and how it works? This approach is bound to repetitive fail.
best regard
Re: vc++ class need run-time library?
I think I am not. Stroustrup thinks I am not. GCC thinks I am not:cyr1x wrote: I think you are wrong here.
Code: Select all
solar@valkyrie ~ $ cat test.cpp
#include <iostream>
class AbstractClass
{
public:
virtual void func() = 0
{
std::cout << "Hello World" << std::endl;
}
};
solar@valkyrie ~ $ g++ -c test.cpp -o test.o
test.cpp:6:29: error: pure-specifier on function-definition
Trying to define a function body and declaring the function pure virtual is showing some degree of ignorance of the construct.
Last edited by Solar on Sun Jun 03, 2012 3:21 am, edited 1 time in total.
Every good solution is obvious once you've found it.
Re: vc++ class need run-time library?
Stroustrup, "The C++ Programming Language". There are others, perhaps even better ones, but this one is "from the horse's mouth" as Stroustrup is the one who invented the language in the first place.hojjatrakhshani wrote:can you give me book or some resource aboute this?berkus wrote: Are you trying to approach C++ programming without actually understanding what C++ is and how it works? This approach is bound to repetitive fail.
One thing though... as a beginner in a programming language, osdev.org is the wrong place to hang out.
PS: Improving your English would also be a definite bonus.
Every good solution is obvious once you've found it.
Re: vc++ class need run-time library?
OK the above snippet was only accepted by Visual Studio.
With GCC this works for me at least:
With GCC this works for me at least:
Code: Select all
class pure
{
public:
virtual void func() = 0;
};
void pure::func() {
std::cout << "Hello world";
}
Re: vc++ class need run-time library?
What are you trying to achieve?
Even if you find a way to get this past the compiler, what do you think you're doing?
Not everything that compiles is legal, let alone "good code". I'm quite confused that this construct compiles, because it doesn't make any sense.
Even if you find a way to get this past the compiler, what do you think you're doing?
Not everything that compiles is legal, let alone "good code". I'm quite confused that this construct compiles, because it doesn't make any sense.
Every good solution is obvious once you've found it.
Re: vc++ class need run-time library?
PS: Found this one on StackOverflow. Apparently it is actually allowable, enabling the abstract base class definition to be called explicitly. Quoting the accepted answer:
Not that this ever stopped C++ from doing it anyway.
Congrats on this one. It's not often that anyone catches me flat-footed in a C/C++ topic.
I second the last statement. I consider myself a war-hardened C++ veteran, and have seen much in my time. You see from the above how much this construct surprised me - and I still think it's a somewhat broken approach.The use case I can think of off the top of my head is when there's a more-or-less reasonable default behavior, but the class designed wants that sort-of-default behavior to be invoked only explicitly. It can also be the case what you want derived classes to always perform their own work but also be able to call a common set of functionality.
Note that even though it's permitted by the language, it's not something that I see commonly used (and the fact that it can be done seems to surprise most C++ programmers, even experienced ones).
Not that this ever stopped C++ from doing it anyway.
Congrats on this one. It's not often that anyone catches me flat-footed in a C/C++ topic.
Every good solution is obvious once you've found it.
Re: vc++ class need run-time library?
Actually this thing surprised me too when I first encountered it.
Re: vc++ class need run-time library?
I'm probably being really stupid, so I apologise in advanced, but once you supply a function definition other than = 0 surely it is no longer a pure virtual function? The same way that a null pointer is no longer a null pointer when you assign a value to it.
As I say, it's probably a stupid remark, so please don't flame me.
As I say, it's probably a stupid remark, so please don't flame me.