C++ :: How To Store Objects To Program

Nov 14, 2013

I've started programming my little program called vLibrary (program I want to make for the library in my city) and after I m done with console application I will try to implement wxWidgets.My program will be able to add new users to the system, new books and new librarians.

Now, I m confused what data types to use and how to store objects (newly created users, books etc) to my program so later on they can log in the system etc. Logic of the program is completely clear to me but I m not sure how to make array of objects and store them in memory or in a certain file, how to store password and make some kind of encryption etc.which data structure from STL should I use and how.

View 2 Replies


ADVERTISEMENT

C++ :: Store Address Of Objects

Oct 27, 2014

I'm using the SDL library and trying to match the C++11 standards... Anyway, I thought about a vector where I store all the addresses of game instances, so I can access them anytime... I tried with this function:

int instance_new(std::vector<uintptr_t> &instance_id, unsigned &instance_size, Instance *pointer) {
instance_id[instance_size] = reinterpret_cast<std::uintptr_t>(pointer);
instance_size++;
instance_id.resize(instance_size);
return 0;
}

Where "Instance" is the 'parent' class of various child classes like the player. So, if I have to search the existing of a thing in my game, I should check if the address references to an instance of class. How can I do this?

View 1 Replies View Related

C++ :: Use Array To Store Class Objects?

Feb 11, 2013

So starting with the Item.h file :

#ifndef ITEMH
#define ITEMH
using namespace std;
class Item

[Code]...

I think I'm getting the wrong idea about strings. I thought I could add data just by using '+=' but apparently not.

View 4 Replies View Related

C/C++ :: Container To Store Objects Under (unique) ID

Jun 14, 2014

I searching for a container/collection, that can access very fast to objects with the associated id.

Arrays are a bad idea, because it can be that I must store objects with a big id for example 9394034, so the array would be to big.

View 7 Replies View Related

C/C++ :: Enter And Store Employee Objects

May 17, 2014

Okay, I'm not entirely certain where my code is messed up, but when I run the console it asks if I want to add Employee information and then it just skips through everything when I say yes.

#include <iostream>
#include <iomanip>
#include <string>

[Code].....

View 14 Replies View Related

C++ :: Compare Data Members Of Objects Store In Vector

Mar 6, 2014

Overview of problem : I am using std::vector to hold objects of Subject. Now this vector contains lots of objects( with lots I mean 10-20 objects at max) . These objects have string member values like category and sub_category. Both category and sub_category can have string which can be same of other objects's sub_category & category.

Issue: Now I want my std::vector to have only those objects whose's sub_category are unique. If category is not unique that's not a problem .

Secondly if we found 2 objects having same sub_category then we have to delete one of them from the vector. we will delete it based on some rules example

Rules for deleting are if

i) instance of Subject ->category = " Land " OR if category = "Jungle" then delete other duplicate object ,
ii) if above condition doesn't match then delete either of them.

I am wondering , how would I compare the sub-items from the vector . For example. I have class say Subject

class Subject {
public :
// some constructors,
// functions to get ., set category and sub category
std::String get_sub_category()
std::string get_category();
private:
std::string category;
std::string sub_category;
}

I have vector which stores object of Subjects. Example : vector<Subject> copy_vector;

Now what I want is to delete the object from vector that has same sub_category I am not looking for source code buT i need a starting point,? Example:

copy_vector[0] = Animal object that has sub_category Tiger
copy_vector [1] = Animal object with Lion as sub category
copy_vector[2] = Forest object with sub_category Tiger

What I want is to based on some conditions(which I can do ) remove either Forest or Animal object containing Tiger. But for that how would I do comparison? I have written the function and have checked it.

std::vector< Subject >copy_vector;
// copy_vector contains all the objects of Subject with redundant sub_category
for( std::vector< Subject >::iterator ii = copy_vector.begin() ; ii != copy_vector.end() ; ++ii ) {
sub_category = ii->get_sub_category();

[code] ....

View 1 Replies View Related

C++ :: Creating Priority Queue Of Objects Transaction As A Variable Of Store Class

Dec 4, 2013

I've got 2 classes, Store and Transaction and I would like to create a priority queue of objects Transaction as a variable of Store class.

My store.h
#ifndef __STORE_H_INCLUDED__
#define __STORE_H_INCLUDED__
#include <queue>
using namespace std;
#include "Transaction.h"
struct TransactionCompare;

[Code] ....

The error im getting with this set up is

error C2664: 'bool TransactionCompare::operator ()(const Transaction &,const Transaction &)
const' : cannot convert parameter 1 from 'Transaction *' to 'const Transaction &'

View 6 Replies View Related

C/C++ :: Program Which Ask For X Numbers And Store Them In Array

Nov 22, 2014

This is in c. Write a program which asks for X numbers, and stores them in an array.

The program then asks the user to enter a number to look for, and tells the user how many times that number appears in the array of numbers (if any), and the array index which contain the number

Make an array of the indexes where the number was found, and then format your output to match my output.

Sample Run:

How many numbers would you like to enter: 5

Please enter a number:1
Please enter a number:2
Please enter a number:3
Please enter a number:4
Please enter a number:2

The numbers you enter were: 1, 2, 3, 4, 2
Please enter a number to find: 2
The number appears 2 times, at array ellements with indexes 1, 4

Press any key to continue . . .

View 10 Replies View Related

C++ :: Design ID To Store Vectors For CAD Program?

Mar 3, 2012

Let's say we have entities like lines and circles. And each entity can have a pen attached. And a pen is a color and line width. All entities needs to be manipulated through a operations interface. All entities added to the program needs to be added through using a factory pattern.

So we end up something like (pseudo code)

class Line // for immutable objects {
..
..
} class MutableLine extends Line //for mutable lines {
} MutableLine line=factory->newLine(20,20,50,50); // Create a new line entity

[code]....

So, essentially I want no code to be able to operate directory on entities, unless during creation of the object (color, layer, line width etc...) so I am planning to create Mutable versions of all entities besides the immutable versions.

When requested for selected entities or all entities, I am planning to return a list of immutable objects and in fact I am planning to return a new copy so it's not possible to operate on anything directly.

The reason is that I am planning to create different storage backends swell, so I can operate on entities in a database, or shared memory... stuff like that. At least to hide the internals and provide a stable API.

My questions are:

How can I make sure that people don't do 'tricks' casts for example to a mutable version to change objects directly?

View 2 Replies View Related

C++ :: Periodic Table Program - Array Of Objects

Feb 4, 2014

I'm writing a periodic table program to understand classes. I want to be able to display/sort the elements by several properties such as whether it's a metal, nonmetal, or metalloid. I'm not sure hwo to do it, but my first guess was to create an array of objects; however, I'm having problems using my constructor to set the values.

Class
class Element{
public:
enum class groupNames { HYDROGEN, ALKALI, ALKALINE, GROUP_THREE, GROUP_FOUR, GROUP_FIVE,
GROUP_SIX, GROUP_SEVEN, GROUP_EIGHT, GROUP_NINE, GROUP_TEN,
GROUP_ELEVEN,GROUP_TWELVE, GROUP_THIRTEEN, GROUP_FOURTEEN,
GROUP_FIFTEEN, CHALCOGEN, HALOGEN, NOBLE_GAS,

[code].....

View 5 Replies View Related

C++ :: Class Objects - Program Not Comparing Two Strings

Jun 20, 2013

I am having difficulty with class objects.

1. why my program won't actually compare the two strings.
2. why and where I am having a memory dump crash.

The following is my main.cpp, String.cpp, and the header file in that order.

#include <iostream>
using namespace std;
#include "GREEN_String.h"
void main () {
GREEN_StringStr1;
GREEN_StringStr2 ("AdrianGreen");

[Code] .....

View 5 Replies View Related

C :: Gradebook Program - How To Store And Access Data

Jun 15, 2013

How I would store all the data. Also how would I access it after I store it. Side Note we are not allowed to use structures or objects.

For the purposes of this gradebook you should first provide a menu with the following options

-Add a new course Add a new student to a course Add grades for a student in a course Print a list of all grades for a student in a course Print a list of all students in a course Compute the average for a student in a course Compute the average for a course Store Gradebook (to a disk file) Load Gradebook (from a disk file)
-Each of these menu items should correspond to a function you will write.
-For the basic program each student will be represented by an ID number And each course by a course number
-Grades will be whole numbers only (no fractional part)

As indicated in the menu you will need to store and load using a disk file so that the data is retained.

Here are so limiting values in defining your data structures: Maximum Number of students (total) 100 Max number of courses 25 Max number of courses per student 4 Max number of grades per student per course 10

View 6 Replies View Related

C++ :: How To Store Variable In Memory When Program Is Closed

Nov 3, 2013

How do you store a variable in memory so that it isn't changed when the program closes? I don't have any experience with this and am just wondering how it is possible. I am creating a program and want it to store your preferences and scores. In a simple program, everything is just reset and I don't want this for my program. How do I store a variable so that it stays the same, but can be changed even when the program is turned off?

View 2 Replies View Related

C++ :: Program To Store Results In Two-dimensional Array

Apr 6, 2013

5. Four experiments are performed and each experiment produces four test results. The results are tabulated as shown below. Write a program to store these results in a two-dimensional array, A[4][5], then use a nested for-loop to compute the average of the test results for each experiment and store it in the 5th column of the array. Print the array.

1st experiment results: | 23.2 | 34.8 | 53.7 | 19.5 |
2nd experiment results: | 34.8 | 42.9 | 28.6 | 35.4 |
3rd experiment results: | 24.5 | 29.5 | 32.0 | 19.3 |
4th experiment results: | 36.8 | 31.6 | 43.7 | 29.5 |

6. Using the srand( ) and rand ( ) C++ library functions, fill an array of 1000 numbers with random numbers that have been scaled to the range of 1 to 100 inclusive. Then determine and display the number of random numbers having bvalues between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?

View 2 Replies View Related

C++ :: Program To Store 10 Decimal Numbers In Array

Sep 24, 2014

Write a program which stores 10 decimal numbers in an array. For these numbers accept input from the users. Once the array is populated do the following:

Display each elements of the array
Display the sum of all the elements of array

View 1 Replies View Related

C++ :: Write Program That Ask His Or Her Name And Store It In Character Array

May 28, 2013

write a program that ask his or her name and store it in a character array

View 1 Replies View Related

C++ :: Store Related Data Of Program Into External File?

May 14, 2013

How is it possible to store the related data of a program C++ into an external file (like as .txt) and retrieve it?

I want to write c++ program that can contain data members " id and phone"

like as
Code:
class profile {
private: int id,phone;
public:
void retriever() {
cout<<"Enter your ID: ";
cin>>id;
cout<<"Your Phone number is "<< phone;
};
}

avoiding formats in above class, purpose is to store data already in txt file with different id and phone numbers and it is to be retrieved by matching id number to txt file and viewing its related phone number.

View 1 Replies View Related

C++ :: Write A Program To Store Marks Obtained By 50 Students?

Feb 28, 2014

Q.1 Write a program to store marks obtained by 50 students. Initialise the array having passed to a function initilise() having passed the array as parameter. Write another function which should take this array as parameter and return the highest score from the array. you have to write the proper function call, prototype and definition for each function.

And this is the program which i wrote and got errors: -

#include<iostream.h>
#include<conio.h>
#define s 50
void init(int m[s]);
void display(int m[s]);
void find_max(int max, int m[s]);
void main(){
clrscr();
int max;

[code]....

View 1 Replies View Related

C/C++ :: Program To Store Info About Students And Then Display To Screen

Oct 7, 2014

NOTES AT BOTTOM---EXPLANTION, PROBLEMS ETC. SCROLL DOWN

#include <iostream>
#include <iomanip>
#include <string>

[Code]....

I have to write a program that stores information about students and displays results (Formated). Example-

Inputs ( # of students, First and Last name of student, the gender, age, and hieght. (height inputed as inches and outputed as feet and inches))

Student 2
---------
Jett, Joan Female
100 years old 5' 7"

Ive been falling behind a little due to working late and barely having time for my school work. Coming across several issues, one being an error with GENDER (Error C4700: uninitialized local variable 'gender' used:). As well as how to format the end result, i understand that u have to use #include <iomanip>, but am confused on how to format correctly.

View 2 Replies View Related

C++ :: Program Read In 15 Integers From User Then Store And Print Out Numbers

Apr 29, 2014

I want to write a program to read in 15 integers from the user, and then store them in a 5x3 array, and print out the numbers as a 3x5 array.

View 7 Replies View Related

C/C++ :: Write Program That Calculate Students CGPA And Store In To File Name

Jan 16, 2015

#include<fstream>
#include<iostream>
#include<string>

[Code]...

View 2 Replies View Related

C :: Display Current Time And Date In Program And Use Variable To Store Each Of Values

Feb 16, 2013

i need to display the current time and date in my program and use variable to store each of the time values like

a = 10
b = 29
c = 31

printf(``%d : %d : %d``, a,b,c);

which then give the output as - 10:29:31

How to save the time in variables in C....

i am using C in windows 7 and my complier is Bloodshed Dev C++

View 7 Replies View Related

Visual C++ :: Program To Calculate Sales Totals For A General Store - While Loops

Jan 25, 2013

I need coding this project using while loops and cout/cin.. It is suppose to be one while loop for the whole thing and inside of the first while loop is the second while loop for each sale separately.

You have been asked to write a program to calculate sales totals for a general store. Your program will not know how many products each customer will buy, so your program will have to repeat the process until the last product has been entered (use -1 for Product ID to end each sale). After each sale your program must ask if you want to do another sale (Y - continue, N - end program).

At the beginning of the day, the cash drawer has $500 in it. At the end of the program you must display how much money is in the drawer after handling all your sales transactions.

Input
Your program must take the following input:
- Product ID Number (int)
- Quantity for each item purchased (int)
- Cash Received at the end of the sale

Use the following dataset to determine the price and taxability for each item.

First Sale:
Product ID Price Quantity Taxable
101 $65.00 2 Yes
102 $12.50 1 No
103 $24.50 5 No
104 $38.75 4 Yes
105 $17.80 6 Yes
106 $16.50 2 No
107 $42.85 8 Yes
108 $32.99 2 Yes
109 $28.75 1 Yes
110 $51.55 1 No

Second Sale:
Product ID Price Quantity Taxable
102 $12.50 1 No
103 $24.50 1 No
106 $16.50 1 No
107 $42.85 1 Yes
108 $32.99 1 Yes
109 $28.75 1 Yes

Third Sale:
Product ID Price Quantity Taxable
106 $16.50 4 No
107 $42.85 3 Yes
108 $32.99 1 Yes
109 $28.75 5 Yes
110 $51.55 2 No

Calculating Tax
For those items that are taxable, assume a 7.5% sales tax. Be sure to keep a running total of tax for the each sale.

Getting Started
You must use the starter file provided with this assignment.
What to turn in:
- A copy of your source code
- A printout of your program's output

View 2 Replies View Related

C :: Program That Can Implement Functions That Store / Get And Deletes Text / Binary Data To Given Memory Area

Sep 19, 2013

I got an assignment at school asking for a program that can implement functions that store, get and deletes text/binary data to a given memory area. We are supposed to make kind of like a tiny-mini OS..any links to some tutorials or explanations hon ow to understand this and be able to make a program like this on my own?

View 9 Replies View Related

C/C++ :: Objects Hold References To Other Objects?

Nov 12, 2014

This has been bothering me for a while now, and I finally put together an example:

#include <iostream>
#include <string>
using namespace::std;

[Code]....

In the code above, the two classes hold pointers to each other, and that's fine but it doesn't seem right since C++ prefers to pass by reference. Yes, it can still do that (see testbox and testball) but even that seems odd to me because still you need to use pointer notation for the enclosed object. Am I the only one who feels this way, and should I just get over it? Or am I missing something that would allow an object to hold a reference?

View 4 Replies View Related

C++ :: Program Should Input Each Student Grade As Integer And Store Grade In Vector

Jun 26, 2013

I get so close, and then it seems my brain shuts down ... I need to write a program that outputs a histogram of student grades for an assignment. The program should input each student's grade as an integer and store the grade in a vector. Grades should be entered until the user enters -1 for a grade. The program should then scan through the vector and compute the histogram. In computing the histogram, the minimum value for a grade is 0, but your program should determine the maximum value entered by the user. Use a dynamic array to store the histogram. Output the histogram to the console. For example, if the input is:

20
30
4
20
30
30
-1

Then the output should be:

Number of 4’s: 1
Number of 20’s: 2
Number of 30’s: 3

I can't quite get my output to look like that:

/* This program will display the histogram of student grades for an assignment */
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <conio.h>

[code]......

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved