View Full Version : someone has to know this! c++
ayastona
April 23rd, 2009, 07:29 PM
hi. the title might be a little confusing.
c++
i am trying to set up variables that have multiple other variables within them..
so for instance i need to enter a persons name and then along with that name i need to specify the persons age and address and a few other demographic informations..
that information will then be written to a file. (which i know how to do... i think....) then i will move to the next person and enter their name and within that persons name i will repeat the process as before...
how do i go about doing this? do i need to create a class? please help!
ayastona
April 23rd, 2009, 07:29 PM
Currently i have been taking the information directly entered by a person using my program and having the information printed into a text file... i may have to make it so that i can search for the information later and so i was wondering what is the best way to handle all-text information so that if i do need to recall it i can easily find it..
right now it just seems to me that by simply placing text into the text file, i am setting myself up for disaster in the future when i have alot of information saved..
thanks!
manuelb
April 23rd, 2009, 09:40 PM
You may want to take a read here (http://crasseux.com/books/ctutorial/Structure-declarations.html#Structure%20declarations).
You can go for a class or a struct, in fact a struct is a class with every member public by default, conversely a class is a struct with every member private by default: there are other differences, but for now you just want to know that the class keyword is available only in c++ and instead concentrate your start on the very basic concept of programming.. just my head up on the matter :)
3Miro
April 23rd, 2009, 09:54 PM
As manuelb said, you need either a class or a struct. In programming (in a very general sense) you have data and functions that manipulate the data. struct creates a data type consisting of several already defined data types (i.e. int for someone's SSN and int for the same person's age). A class incorporates data and functions together in a structured way.
My advice is to learn the basics of structs first and then moving to classes should be easy.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.