|
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
|
|
|
|
|
FILE *handletofile;
handletofile = fopen("pathtofile", "a+"); //open the file
fscanf(handletofile, "%s", string); //for reading
fprintf(handletofile, "%s", string); //for writing
fclose(handletofile); //close file (do not forget!)
fread and fwrite for binary files.
use fseek to set your pointer to a specific place in the file.
do not open in beginning of exec. and close at end. open/close more often to flush the text and to have something in case your program crashes.
Good Luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
hi,
Can you say something more about fseek please?
how to use fseek to go to a certain line of a file.
For examlpe, I need to overwrite the thrid line of the file.
But fseek and fgetpos simply moving the file pointer in the same line, not be able to next line.
Thankx.
chauteen
|
|
|
|
|
doesn't fscanf read the "\t", "\n" characters? if so. read the entire file in CString and handle the CString.
(you can always google, Codeguru, codeproject on tutorials and examples.)
info on fseek from MSDN:
Run-Time Library Reference
fseekSee Also
Stream I/O Routines | ftell | _lseek | rewind | Run-Time Routines and .NET Framework Equivalents
Requirements
Function Required header Compatibility
fseek <stdio.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP
For additional compatibility information, see Compatibility in the Introduction.
Libraries
All versions of the C run-time libraries.
Moves the file pointer to a specified location.
int fseek(
FILE *stream,
long offset,
int origin
);
Parameters
stream
Pointer to FILE structure.
offset
Number of bytes from origin.
origin
Initial position.
Return Value
If successful, fseek returns 0. Otherwise, it returns a nonzero value. On devices incapable of seeking, the return value is undefined.
Remarks
The fseek function moves the file pointer (if any) associated with stream to a new location that is offset bytes from origin. The next operation on the stream takes place at the new location. On a stream open for update, the next operation can be either a read or a write. The argument origin must be one of the following constants, defined in STDIO.H:
SEEK_CUR
Current position of file pointer.
SEEK_END
End of file.
SEEK_SET
Beginning of file.
You can use fseek to reposition the pointer anywhere in a file. The pointer can also be positioned beyond the end of the file. fseek clears the end-of-file indicator and negates the effect of any prior ungetc calls against stream.
When a file is opened for appending data, the current file position is determined by the last I/O operation, not by where the next write would occur. If no I/O operation has yet occurred on a file opened for appending, the file position is the start of the file.
For streams opened in text mode, fseek has limited use, because carriage return–linefeed translations can cause fseek to produce unexpected results. The only fseek operations guaranteed to work on streams opened in text mode are:
Seeking with an offset of 0 relative to any of the origin values.
Seeking from the beginning of the file with an offset value returned from a call to ftell.
Also in text mode, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading/writing, fopen and all related routines check for a CTRL+Z at the end of the file and remove it if possible. This is done because using fseek and ftell to move within a file that ends with a CTRL+Z may cause fseek to behave improperly near the end of the file.
Requirements
Function Required header Compatibility
fseek <stdio.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP
For additional compatibility information, see Compatibility in the Introduction.
Libraries
All versions of the C run-time libraries.
Example
// crt_fseek.c
/* This program opens the file FSEEK.OUT and
* moves the pointer to the file's beginning.
*/
#include <stdio.h>
int main( void )
{
FILE *stream;
char line[81];
int result;
stream = fopen( "fseek.out", "w+" );
if( stream == NULL )
printf( "The file fseek.out was not opened\n" );
else
{
fprintf( stream, "The fseek begins here: "
"This is the file 'fseek.out'.\n" );
result = fseek( stream, 23L, SEEK_SET);
if( result )
perror( "Fseek failed" );
else
{
printf( "File pointer is set to middle of first line.\n" );
fgets( line, 80, stream );
printf( "%s", line );
}
fclose( stream );
}
}
Output
File pointer is set to middle of first line.
This is the file 'fseek.out'.
See Also
Stream I/O Routines | ftell | _lseek | rewind | Run-Time Routines and .NET Framework Equivalents
--------------------------------------------------------------------------------
Send feedback on this topic to Microsoft
© Microsoft Corporation. All rights reserved.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|