|
Hi,
class Client;
Client(const Client&);
The above code compiles fine with VSC++6.0, when same is compiled with VSC++ 2008 throw’s the following is the compilation error "error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"
Then I have changed the code as below, it got compiled with VSC++ 2008.
Client(const &Client);
So can any one help me what is the cause of the problem and whether this "Client(const &Client); " is correct approach.
Thanks,
Nandu
modified on Friday, September 18, 2009 7:48 AM
|
|
|
|
|
What is that code even meant to mean? You've forward declared a class (Client), then what looks a bit like a constructor for that class. Doesn't make sense.
Oh - and VS2008 is complaining because you haven't specified a return type for what looks like a function declaration of a function called Client.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks, I got the answer.
In VS6.0 Client(const &Client); compiles fine, where as in VS2008 it throws compilation error.
For VS2008 it should be Client(const Client&); - For copy con
-Nandu
|
|
|
|
|
So…lets look at the code you posted:
class Client;
Client(const Client&);
and what (judging by your answer) you should have posted:
class Client
{
Client(const &Client);
};
Your original code was syntactically incorrect and at the same time had the syntax (const Client&) that you now report as fixing the problem. If you're going to post problems with a code snippet, at least make it an accurate code snippet...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi to all,
Thanks everyone for my previous doubt. Here's is one more.
Sometimes, we say (when it comes to the basic difference between class and object) that class is a logical entity and object is a physical entity. But actually is it so? We still can use the size of operator to check the size right...and it gives some sizes.
If I make sense, what should be the correct statements?
Also please tell in t=context of static member function in a class
Thanks in advance
-----------------------------
I am a beginner
|
|
|
|
|
Think of the int datatype.
That is also logical.
It's only when you create a variable like int i; does it becomes physical.
But you can always take the size of int using sizeof(int) .
classes and objects are very similar.
The size of a class is the total size of the non-static data members of the class.
When static is used in a class, those elements are actually global but the scope of it is limited to the class.
The size will also include hidden elements like the virtual table pointer etc.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
thanks
I got that.
So,what i understood is , the result of the Sizeof operator is the amount of space that the variable of that type(int/class) will contain. So even though iit is not physical we get the results of sizeof.
But does the class resides on memory? when we say its not physical, it shouldn't exist in the memory right.Please correct me, if i am wrong.
-----------------------------
I am a beginner
|
|
|
|
|
hrishiS wrote: But does the class resides on memory? when we say its not physical, it shouldn't exist in the memory right.
You may say it is metaphysical...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
No, the class does not reside anywhere.
It is only used by the compiler to create an object.
All class data members are referenced using offsets from the begining.
All class methods are actually global functions.
The functions get the address of the object through the ECX register (at least when compiled with Visual Studio). Or this could be passed in as a hidden first parameter.
To locate the data members, this object address is then added to the offsets.
When you do a new MyClass; what happens internally is malloc(sizeof(MyClass));
If you simply create a class and don't use it, it will never have a life.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi, object is physical entity and allocation of memory is done based on the variables which we are using in that class. Suppose I used 2 integer variables and 1 float variable in my class then each object for this class occupies (2+2+4)bytes of memory. You can able to see this by using sizeof(object name) then it will gives you 8 bytes as a output. This result may vary based on the compiler used I am giving this based on the TC(turbo C)
And coming to the static variable is never possible to create inside a class. Because for a static variable the memory is allocated at compile time where memory allocated for an object at run time. So both things are contradict. When ever you tried to create an static variable inside a class it will gives you an error.
sampath-padamatinti
|
|
|
|
|
I am new to VC8 and simply cannot find how to change fonts and colors of the source code editor. Any hints?
Thanks
uli
|
|
|
|
|
tools->options->Environment->Font and colors
|
|
|
|
|
what is the use of STL ??
~Raju~~
|
|
|
|
|
rajugis wrote: what is the use of STL ??
It depends on your background.
(as a start, you may have a look here)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
A generic answer would be: STL is used to write C++ programs.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Think in terms of what is the use of a library.
It will contain several already implemented routines.
Like a Math library would have functions to do matrix multiplication and addition.
Similarly STL is a templatized library used for generic programming and contains several containers and algorithms.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
We know the different kind of data structures called stack, queue list etc. So for this kind of things when you want to create list you have to write entire code for this. And also you must and should specifies the type list, where as coming to the STL you need not bother about the things. There we have ready made data structures available to perform our operations. So we need not write the operations again and again directly we can use this data structure by using standard name space. One more advantage when we use this is we need not to write logic for sorting, traversing etc. there we existed some ready made functions which can accomplish our work very easy manner.
sampath-padamatinti
|
|
|
|
|
Hey Buddy Every language has set of functions which will come with ur complier as STL u can Perform operation easily so that the developing time for the code is reduced and where progrmmers can concerntrate on other issues and get the things done faster in application development.
For example lets take an array contains group of elements if we want to sort that array we have to write code manully and execute it instead if we go through some set of STL functions we can sort them if we just use the functions...
To say u simply a predefined set of Functions which works on the set of Data Structures to get the things done in faster and efficient way...
Regards,
Pravin.
|
|
|
|
|
in mysql database, I created 2 fields INT(64) and INT(96).
This is first time I use integer field over 32 value, I need your comments and experiences to read/write the fields.
How do you treat them in your program?
BTW:
reading from db returns a buffer (char*) and buffer length, which looks like "328273645272829292291993933838".
|
|
|
|
|
you must convert the string to a number the right way. Cant you get the number right of the DB. Maybe in the is number. -> Type cast.
Or ind an API-function or write one. It depends on what the DB returns. Read the docs of the DB.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
For 64-bit integers you can use _atoi64[^], which returns __int64.
There is no 96-bit integer in standard C++ so you will have to use a library for example bigint[^].
Saurabh
modified on Friday, September 18, 2009 5:38 AM
|
|
|
|
|
Hi,
Could anyone please tell me the exact use of pure virtual function in C++. (ie the abstract class)
I understand the concept. But I want to know in which situation we really need those? Or basically what is the practical use of it?
thanks
-----------------------------
I am a beginner
modified on Friday, September 18, 2009 2:42 AM
|
|
|
|
|
hrishiS wrote: Could anyone please tell me the exact use of pure virtual function in C++.
Roughly speaking is what you need in order to design interfaces.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks for your reply pallini,
But there is always a small difference between the abstract class and interface. Anyway, when we talk about interface also, when do we need/use them exactly?Could you please give me a practical example.
-----------------------------
I am a beginner
|
|
|
|
|
hrishiS wrote: But there is always a small difference between the abstract class and interface
No, there isn't - not if the abstract class has a) no data, and b) declares all of it's methods to be public and abstract.
hrishiS wrote: Anyway, when we talk about interface also, when do we need/use them exactly
When you want to define some API you want a class to conform to, but don't want to constrain the implementation beyond that. For example - look at COM - that's ALL interfaces. For a more practical example, let's look at iterating through some collection of objects:
template<class T>
class IIterable
{
virtual void First() = 0;
virtual bool Next() = 0;
virtual const T& Current() const = 0;
};
This tells you what methods have to be implemented, and should also define the semantics of the methods, but does not constrain the implementation...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|