Advertisement

Object C++ help

Started by January 16, 2002 02:11 AM
7 comments, last by Holocron 22 years, 10 months ago
Is it possable to save an instance of an object to a file? If so how is this done and how do I call that object onced its saved? Thanks
I think what u need to do is to make a .dll file
Advertisement
Standard C++ doesnt have any native serialization mechanism - if you want object persistence you have to implement it yourself by saving all the fields to disk and restoring them.



Once there was a time when all people believed in God and the church ruled. This time is called the Dark Ages.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Sorry to post my questien here but i havent registret me so i cant creat new topics plz help me.


Whats the diffrent between c programing code in dos platform and windows platform.
I am using borland c++ but writes with c code. In my whole life i been programing in dos but now i want to change to windows. I got some problem.
1. When you programing in borland c with windows platform you just dont have cpp text file you have also def and rc files.
what do you have to write there to make a program that just type
"Arne vajse"
2. When I type as i type in dos platform with printf("Arne vajse"; it doesnt work why.
3. I have for a long time tried to make graphics in c with dos platform I have tried to copy the help files exampel for graphics but it doesnt work either why

plz help.

Mullvad
Holocron, the closest you could get to that using the standard library is to use fwrite.

Anonymous Poster:

Those extra files have nothing to do with the language, I'm sure you know. .rc files are called resource scripts. They contain the information necessary for a "resource compiler" to put the resources used in your application into the generated executable. Resources are things like icons, cursors, and dialog templates that your application uses, and they'll become part of your executable. .def files are only pertinent when making DLLs, as they define which functions are to be exported (visible to apps that use the DLL). However, this method is pretty much unnecessary with Visual C++'s __declspec(dllexport) </i> keyword.<br><br>It depends. Windows has two subsystems: the GUI and the Console. The GUI is, of course, the bit you normally work with that has windows and menus and all of that. The Console is mistakenly called DOS, but it's simply a text-based interface that looks like DOS, Linux, and other text-mode interfaces. If you're making a Console app (in Visual C++ this kind of project is called "Win32 Console Application"), <i>printf </i> will work just fine. But if you're making a GUI app (in Visual C++ this kind of project is called "Win32 Application"), you'll have to use something different. Since the GUI subsystem has no console, <i>printf </i> won't work because <i>printf </i> directs output to a console. Think about it this way. If you had made Windows, where would you make <i>printf </i> output go in the GUI? Would you have it create a new window with the text in the center? Would you draw it on the desktop? There are millions of possible answers, so that's why <i>printf </i> just does nothing in the GUI. So, you have to implement one of those options yourself. If you want to display text using a message box, use the <i>MessageBox </i> function. If you want to display it in a window, create a window and use <i>DrawText </i> or <i>TextOut </i> to draw it when you handle your window's <i>WM_PAINT </i> message.<br><br>DOS headers and libraries can never be used under any other platform than DOS. Headers like <i>dos.h </i> and BGI stuff are for DOS only. So, you'll have to do graphics another way. One way is to use the GDI (Graphical Device Interface), but I don't have the time to explain all of that to you. Does anyone around here know of any good tutorial sites?<br><br>Edited by - merlin9x9 on January 16, 2002 4:36:15 PM
quote: Original post by Anonymous Poster
Sorry to post my questien here but i havent registret me so i cant creat new topics plz help me.

it would probably take you as long to register as it did to type this message...
quote: Whats the diffrent between c programing code in dos platform and windows platform.

well, the basic c is the same, but you need to use the Win32 API for the windows (input/output/forms) part. instead of main() you use WinMain(), and you have to handle creating your windows and dealing with their messages. i''d recommend buying a windows programming book, but you can also check out www.winprog.org for a tutorial and a few helpful hints.
quote: 1. When you programing in borland c with windows platform you just dont have cpp text file you have also def and rc files.
what do you have to write there to make a program that just type
"Arne vajse"

rc files are for resources; that is, you can compile menus, icons, graphics, or whatever other data you like directly into the EXE (it makes the EXE larger but you don''t need separate files for them anymore). you do not need them, although they aren''t hard to figure out or use, and they make your project easier to manage.
def files are (i think) used for using DLLs from your program (i dunno though, but i can assure you that they aren''t necessary for a simple windows program as i have made simple windows programs without them)...
the thing with windows is that there isn''t any place to "type ''Arne vajse''" to... you must make a window, then put the text on it... i''m sure if you search around (or check out the website i mentioned earlier) you can find many many "hello world" tutorials...
quote: 2. When I type as i type in dos platform with printf("Arne vajse"); it doesnt work why.

you have no place to printf to...
quote: 3. I have for a long time tried to make graphics in c with dos platform I have tried to copy the help files exampel for graphics but it doesnt work either why

i don''t know. that is far too vague a question... what/how exactly did you try to make graphics? did you include the proper headers/libraries and stuff?

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Advertisement
wow merlin9x9, you beat me to it by 17 seconds...

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
That happens to me all the time.
Thanks for the help you are to kind but dont stop being it.
thanks Krez and merlin9x9.

Mullvad

ps. Now when I know how good this websites members are in helping you with qustien i think i will registret!! ds

This topic is closed to new replies.

Advertisement