|
|
As i think we can add methods to Structure tooo
is it ?
any other difference
Assume it was interview Question to me
|
|
|
|
|
You can add methods to structures. I can only see that you can't inherit from structures. No polymorphism.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
it means simply that if we not inherit structures ,,
then we can not attain the Concepts of OOP with structers.. is it.
any other difference ??
thanx
|
|
|
|
|
I can't think of any other difference.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Antony M Kancidrowski wrote:
I can only see that you can't inherit from structures.
Have you not seen the CRect class? It is derived from the tagRECT struct. This is perfectly legal:
struct s
{
};
class c : public s
{
};
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
That isn't a struct inheriting from a struct, which is what I meant. Point taken however.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Antony M Kancidrowski wrote:
That isn't a struct inheriting from a struct, which is what I meant.
But this is:
struct s1
{
};
struct s2 : public s1
{
};
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
OK, I have learnt something new. I have never seen such a struct definition. Noted and commited to memory.
Thanks David
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
in c++, a class and a struct are the same, except that in the case of a struct, members are public by default, and in a class, members are private by default.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
2)C++ structure and C++ class
Actually, C++ structure and C++ class are very closely realated. With one exception, they are interchangeable because the structure can also include the data, and the code that manipulates that data, in just the same way that a class can. The only difference between a C++ structure and a class is that, by default, the members of a class are private, while the members of a structure are public (This also clears up an error I made in the first lab). Aside from this distinction, structures and classes perform exactly the same function.
Here is an example of a structure that uses its class-like features.
One last point just in case you are curious about it. A structure defines a class type. Thus, a structure is a class. This was intentional on the part of the inventor of C++ -- Bjarne Stroustrup. He believed that if structures and classes were made more or less equivalent, the transition from C to C++ would be eased.
http://www.cs.uregina.ca/links/class-info/210/LabFAQ/
There it is...
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
There's nothing more to tell. In C++ a struct is a class with public access to members and public inheritance by default. They have all the same features.
|
|
|
|
|
Technically, that is the only difference.
From a conceptual standpoint, though, struct is customarily used for entities that just serve as convenient buckets to hold data, where class isused for objects.
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|
|
Hi!
I need to know how do i find out the time required to copy a set of files on the disk.
The explorer can tell me how much more time is needed to copy the files. ("35 seconds remaining" kinds).
What are the API's that I can use for this purpose.
Thanks in advance,
Pavan.
|
|
|
|
|
pavanhere wrote:
What are the API's that I can use for this purpose.
I don't think there is such an API.
I think explorer is dynamically estimating that time, possibly based on transfer speed and file size.
I Dream of Absolute Zero
|
|
|
|
|
Explorer seems to count the total number of files remainging, and multiply the time it took for the last file to copy by that. At least that is my only explination for why copy times jump from 45 minutes to 100 minutes back to 50 all the time in long copies.
A better alogrythm would be something like count the bytes done already, the bytes total, and the time used so far. Time remaining = bytes done * time used / total bytes. Or something like that, simple math, but if you don't wish to check and understand the math you shouldn't impliment it. Course this assumes you know the total bytes, which you can count, but that takes time you could use for the copy.
|
|
|
|
|
On the other hand, if you added up the total bytes first, and examined your destination, you could also offer the user a "all these files won't fit" message, which I sometimes SORELY miss when I started a copy process that is going to take 20 minutes, only to come back and find out the last 50 files did not copy becasue I ran out of disk space or something. So there sometimes is a benefit to operations that might seem to take longer on the front end.
|
|
|
|
|
How does one start an app from inside one's code. For example, I have an app called myapp.exe. How do I start it from within a new program. Do I need to bring up an instance of a console and pipe "C:\MyFolder\myapp.exe" to it? Thanks.
|
|
|
|
|
ShellExecute
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
read this[^] from the CP FAQ
I Dream of Absolute Zero
|
|
|
|
|
CreateProcess() is by far the most useful method IMO
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
how to get the current working directory in MFC app Wizard (vc++), i have the code but it is working in Winconsole (vc++),but the same code is not working in MFC app Wizard, is there there any alternative code in MFC app wizard..
//
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}
void main()
{
char CurrentPath[_MAX_PATH];
GetCurrentPath(CurrentPath);
printf("%s" , CurrentPath) ;//using messagebox instead of printf in mfc it is not working
}
|
|
|
|
|
Use GetCurrentDirectory WIN32 API.
|
|
|
|
|
Hi
I need to open a text file, edit it, then save it with these modifications, how can I ?
|
|
|
|
|
fopen(<font style="color:gray;">"C:\\folder\\file.txt"</font>, <font style="color:gray;">"a+"</font>);
TOXCCT >>> GEII power
|
|
|
|