473,466 Members | 1,336 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ARRAYS Please Help

4 New Member
class machine
{
private:
bool running;
bool down;
bool awaiting_repair;
bool being_repaired;

public:
void operation();
void down_machines();

};


void machine :: operation()
{
srand (time(NULL));

rand()%10;

if (rand()%10 == 0)
{
cout << "Machine is down." << endl;
}

else
{
cout << "Machine is running properly." << endl;
}
}

void machine :: down_machines()
{
srand (time(NULL));

rand()%2;

if (rand()%2 == 0)
{
cout << "Machine is under repair." << endl;
}
else
{
cout << "Machine is awaiting repair." << endl;
}
}


How do I put this into an array?
Dec 12 '06 #1
3 1135
Ganon11
3,652 Recognized Expert Specialist
The same way you would create an array of a simple type:

Expand|Select|Wrap|Line Numbers
  1. int x[5];
  2. bool isDone[10];
  3. machine myComputers[25];
Dec 12 '06 #2
skididdy
4 New Member
The same way you would create an array of a simple type:

Expand|Select|Wrap|Line Numbers
  1. int x[5];
  2. bool isDone[10];
  3. machine myComputers[25];

Ganon
I'm a first semester student. This assignment has me going bald. I've got the class down....but I dont see how to use the "simple type"....I dont know where to start!!!
Dec 12 '06 #3
willakawill
1,646 Top Contributor
Ganon
I'm a first semester student. This assignment has me going bald. I've got the class down....but I dont see how to use the "simple type"....I dont know where to start!!!
A simple type is an integer, float, char etc that you are familiar with by now.
to declare an array of a simple type, as gannon says, just do his example.

You can declare an array of your machine class the same way as he has shown.

Expand|Select|Wrap|Line Numbers
  1. machine mymachinearray[23];
Only one set of code will be used and 23 sets of data.
access your code:
Expand|Select|Wrap|Line Numbers
  1. mymachinearray[3].operation();
Dec 12 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Bryce Maschino | last post by:
hello, i am trying to make a java program that will take several different arrays and search through them in a loop suchs as: for (i=0; i < 5; i++) { if (firstarray<such and such { blah blah
5
by: JezB | last post by:
What's the easiest way to concatenate arrays ? For example, I want a list of files that match one of 3 search patterns, so I need something like DirectoryInfo ld = new DirectoryInfo(searchDir);...
1
by: Kurt Richardson | last post by:
Hi all Sorry to bother you with what is probably a really trivial question for you C++ experts. My programming skill are pretty amateur, but I'm pretty good at VB.NET. However, I'm wanting to...
6
by: joelperr | last post by:
Hello, I am attempting to separate a two dimensional array into two one-dimensional arrays through a function. The goal of this is that, from the rest of the program, a data file consisting of...
8
by: scythetleppo | last post by:
I am new thanks for the help. I have a text file set up like this: word1a<tab>word2a<tab>word3a<tab>word4a word1b<tab>word2b<tab>word3b<tab>word4b word1c<tab>word2c<tab>word3c<tab>word4c I...
1
by: Anan18 | last post by:
write a program that declares three dimensional arrays named volts, current, and resistance. Each should be declared in main () and should be capable of holding ten double precision numbers. The...
4
by: selam | last post by:
I have this assignment using c++ please help me in writing a code. Suppose you have a main ( ) with three local arrays, all the same size and type (say float). The first two are already initialized...
4
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
2
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I...
110
by: fjm | last post by:
For some reason, I have always had a hard time understanding arrays as they pertain to php and databases. I understand associative arrays just fine but when there are multidimensional arrays, I kinda...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.