C++ :: Initializing And Declaring Arrays In Classes?
Jan 23, 2012
I'm picking up C++ by translating java code to C++. I have the completed code in java and it works perfectly. I'm not going to paste the whole code, this is a part of what I have:
Code:
class Graph
{
final int MAX_VERTS = 20;
[Code]....
I know it looks almost exactly the same as its java counterpart. I have several sources opened, but it's all bits and pieces of what I need.
View 7 Replies
Mar 31, 2013
We are learning how to use composition. In this project there is the Main (), resistor .cpp and .h, capacitor .cpp and .h, and filter .cpp and .h. I have 4 arrays built in the resistor.cpp that I want to print through the main(). I put the arrays in the constructor and have watched them initialize with the proper values, but as soon as the program leaves the constructor the values are wiped away and the elements are left with the value " -858993460 " in all of the them.
Here is the code:
Filter Main()
#include "Capacitor.h"
#include <conio.h>
#include "Filter.h"
#include <iostream>
#include "Resistor.h"
#include <windows.h>
#include <iomanip>
[Code] .....
View 9 Replies
View Related
Oct 23, 2013
Here are the steps to this program:
1. Declare an array that will hold 3000 numbers
2. Initialize this array by assigning a random number to each element in the array
3. Traverse the array, modifying the current contents of each element in the array so that each value now lies between -3000 and 3000 inclusive
4. Traverse the array to compute the average value of all elements
I have never worked with arrays before and am lost!
View 2 Replies
View Related
Feb 24, 2013
What is the general syntax for declaring two-way friendship in 2 classes?
View 1 Replies
View Related
Oct 23, 2013
I'm just wondering, why you have to set the length of the inner arrays declaring a function. In which moment does the code needs to be sure about the length of the inner arrays accessing an cell?
I came up with this question realizing the elements of the outer array beeing pointers to the first value of each inner array. Therefore I can access e.g. the first first element of the second inner array like this:
**(arr + 1) ...regardless of the length of any array to my mind.
parallel post: [URL]...
View 6 Replies
View Related
Apr 1, 2014
According to [URL] ....
" char myword[] = { 'H', 'e', 'l', 'l', 'o', '