Hi to every body...:D
I'm a novice C++ programmer & I've a question,
How can I write a class as follow to a file...
Class A
{
public:
// Accessors Methods... 2 1667
On 2007-09-29 23:29, ba********@yaho o.com wrote:
Hi to every body...:D
I'm a novice C++ programmer & I've a question,
How can I write a class as follow to a file...
Class A
{
public:
// Accessors Methods...
.
.
.
private:
int itsAge;
string itsName;
// char itsName[ 80 ];
};
I know that, I should use ofstream &....
but there is a problem:
"itsName" is a "string or char*" & It can not be written in desired
file...
Actually it is a char array, and nothing else.
Should I write a self writting method for this class to write itself
to a file or what?
Decide on a file-format for writing you class, then implement
std::ostream& operator(std::o stream& o, const A& a);
so that it writes the members of A in the correct format. For more
information search for serialisation, also take a look in the FAQ: http://www.parashift.com/c++-faq-lite/
--
Erik Wikström
Hi,
Thanks alot...
I got the Clue...
It's good to have such a community... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: verb13 |
last post by:
In an asp page in localhost I have this:
Set x = Server.CreateObject("Scripting.Dictionary")
And I get this error: Invalid class string
If I omit Server like this:
Set x = Server.CreateObject("Scripting.Dictionary")
I get this error: ActiveX component can't create object:
'Scripting.Dictionary'
In the same asp page this works fine:
Set conn = Server.CreateObject("ADODB.Connection")
|
by: Paul |
last post by:
Help, please, I can't get any addins working on a new machine. I registered
the correct plugin names into the right registry location. I gave
VSControlHostLib with a strong name, created the interop assembly, put them
both in the GAC. On my main development machine plugins work OK. On this new
machine no plugins work (not even the ToolWindow example). I keep getting
this error message when invoking EnvDTE.Windows.CreateToolWindow:
...
|
by: Fei Liu |
last post by:
In Accellerated C++, the author recommends that in a header file one should
not declare
using std::string, using std::vector etc instead one should directly specify
the namespace specifier in code.
for example, this is bad practice:
header.h
#include <string>
using std::string;
|
by: chris_doran |
last post by:
/COMMENT has been removed from the linker that comes with VS2005, and
use in source code of:
#pragma comment(exestr, "this is a string")
gives the message:
warning LNK4224: /COMMENT is no longer supported; ignored
and doesn't put the string in the exe file.
|
by: lovecreatesbea... |
last post by:
Is it correct and safe to compare a string object with "", a pair of
quotation marks quoted empty string?If the string object: s = ""; does
s contain a single '\'? Is it better to use std::string::size or
std::string::empty to deal with this condition? Thank you.
string s = "";
if (s == "");
if (s.size == 0);
if (s.empty());
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |