where num1 and num2 are arbitrary numbers. and Terrain is the class of objects I'm trying to store.
I want to be able to use push_back on both the main vector and the vectors within the mapArray vector but I'm unsure of how to target the inner vectors with push_back. How to dynamically store a 2D array of objects.
I have an array of pointers to Mat objects (an OpenCV class used to hold info and data about an image), which I will use to store the images. The function imread reads an image and returns a Mat object loaded with the relevant data about the image.However, this gives me a nice segfault when the assignment takes place. Of course, I can swap it with the following code, but since I'm working with big images (2048x2048 and upwards), it's really inefficient:
for(unsigned int i = 0; i < MAX_IMAGES; i++) { imageName[11] = 49 + i; datacube[i] = new Mat(imread(imageName, -1)); }
Is there any way to do this elegantly and without much hassle?Again, excuse my rustiness and anything completely stupid I might have said. It's been a long time since I worked with C++. Managed to circumvent the problem by using a STD vector instead of an array. I'd still like to know the answer to this riddle...
I have a data structure defined up here called this:
typedef list <classSpec*> ClassSpecList;
I'm trying to add stuff into the list here based on functions that return certain values of that match the same data type. In one function, I have a list pointer object defined here and I have another statement that calls a function.
Im creating a program for a race. The Race class has a vector of results and each element of that vector is a pointer to a result. The Result class has a Time and a pointer to a Participant. So in each race there are various results and it is a result for each participant.The Time is a class that has hours, minutes and seconds. How can I sort the vector of results from the result of the participant with the fastest time to the result of the participant with the slowest time?My code is like this:
//.h file: class Time { unsigned int hours; unsigned int minutes; unsigned int seconds;
Im creating a program for a race. The Race class has a vector of results and each element of that vector is a pointer to a result. The Result class has a Time and a pointer to a Participant. So in each race there are various results and it is a result for each participant. The Time is a class that has hours, minutes and seconds. How can I sort the vector of results from the result of the participant with the fastest time to the result of the participant with the slowest time?
Im getting some errors in my code. I put the error as comments in the code. Each error is after the line where it occurs. My code is like this:
Using SFML, I had a Board class which held multiple vectors of all of my object types in the game, and then it also held a vector of pointers to the memory addresses of these object instances, like this
class Board{ //... std::vector<AbstractObject*> GetAllLevelObjects(){ return allLevelObjects; } //so these are used to hold my object instances for each level
[Code]....
When looping through this vector and drawing the sprites of the objects, I get the runtime error 0xC0000005: Access violation reading location 0x00277000. I solved this error by storing the vector of pointers in the class that holds my Board instance, but I'm wondering why only this solution worked? Why couldn't I just have my vector of pointers in the same class that the instances of those objects were in?
Code: void Class1::Func(shared_ptr<type1> parameter) { } or void Class1::Func(const shared_ptr<type1>& parameter) { } or Should I ever pass arguments/parameters to other objects using shared_ptr's or raw pointers?
#include <string> #include <vector> using namespace std; class Question { string title; vector<Thing*> posAns; vector<Thing*> negAns;
[Code] ....
error: no instance of overloaded function 'std::vector::push_back()' matches the arguments list argument types are (const Thing *) object type is: std:: vector<Thing *, std::allocator<Thing *>>
So it cannot be constant, what if I just leave it non-constant? Will it be safe?
#include <iostream> using namespace std; class superclass; class subclass1; class subclass2;
[Code] ....
As you can see I want to create a dynamically allocated storage of references to a parent class each of which can then point to a child class, how ever I do not know how to extract the child class out again from that array so i may access its variable b.
void armazenaFA( std::vector <int> &vFA) // this function only knows about vFA { vsFA[n] [m]= simTime().dbl(); OR vsFA[n].push_back(simTime().dbl()); }
This is probably a very basic question, but I need to create two vectors and then loop through the vectors and output each pair that is found.
The user will input min1 and max1 with step1 for the first vector and min2 and max2 and step2 for the second vector. Then the loops will go through and return the combinations will return each pair of the two vectors.
So if I input min1=1 and max1=10 and step1=1 and same for vector two the return would be:
[1,1] [1,2] . . . [10,10]
This is for part of a homework assignment, but I can't continue on the assignment without first getting this simple part to work.
It is suppose to display the message "This Account ID does not exist" but why do I get "segmentation fault"??I was able to compile and run the program so it shouldn't be a problem of the compiler.
I'm trying to do is write a program that fits to a separate test program. The test program provides different size vectors that my function should try and binary search. If the element is found, the function should return 1, and if the element is not found, it returns -1.
Here is the code:
int binSearch(const vector<double> & data, int elem, int & comps) { { int beg=data[0]; int end=data[data.size()-1]; int mid=(end+beg)/2;
[Code] ......
The problem is that one of the vectors my function is supposed to binary search is a vector of size 0. I tried to throw in an if statement that would return -1 if the size was == 0, but then the program never fully completed and just kept running. So, how can I account for a size 0 vector in my function?
as i am doing an encryption program on a playfair cipher. I am now stuck on a problem on decryption.If my string is helloworld (without a space), it will decrypt normally.However , if my string has a space in between it. Let`s say Hello World, it will not decrypt normally.How do i take into account the space that is in between hello & world?
I want to create user account and login to windows. I have to read username from DB and create window user for login to window. So,Can I create windows account and login to windows with C#
I am trying to make a for loop that will print out chars in an array while using a #define before main. My problem is that each name has a different amount of chars in it. How do you account for that when you are trying to define a size? For example, I am playing around with the numbers and I just put 7 in for size:
This exercise should familiarise you with loops, if-then-else statements, and recursion. You will have to design and implement a program that calculates the interest earned on a bank-account. Deadline is the end of Tuesday in week 4.
Interests are compounded; that is, you earn interest on interest. Given a yearly interest rate of say, 6%, you can calculate the total sum available when an initial sum of 4000 pounds is put away for 13 years as follows:
4000 * ( (1 + [6/100])^13 ) = 8531.71 pounds
where the caret symbol denotes 'to the power of'. One way to calculate the power is by repeatedly mulitplying. Ie, you can mulitply 1.06 with 1.06 12 times to calculate 1.06^13.
PART 1
Design and implement a function that raises X to the power Y for a real number X and a positive integer Y. The function must use a while loop.
Design and implement a main program that calculates the sum availble when 1000 pounds has been put away for 25 years with 5 percent interest.
Change the while-loop in the function to a for-loop.
I need to modify the program to use annual interests rates of 3%, 4%, and 5%.
After that I need to modify the program to make it so the user enters the dollar amount of the deposit, the interest rate or rates, and the number of years.
I'm a design student at New England Tech but before we can go full design they want to make sure we know for sure if we want to be a designer or a programmer and so we need to take C++ classes
Is there a way to know from a Windows service application (running as a local-system) if a specific logged in interactive user account is configured with a roaming profile? I need this to be compatible with Windows XP SP3.
i am currently doing a mini bank account system using visual studio...i need using the header files...the question requires to use 3 header files for each class.these are the classes:
a)Accounts b)CurrentAccounts c)SavingAccounts
i have done the first part... how to do a new class in a different header file..
I have an odd compiling error. My base class is all delcared and read to go. But I could not figure out how to get my sub classes inherit from it. So I had to make everything public. Even inheriting using the protected inheritance thingy, still could not get them to inherit from that base class.
So I compiled the program, and no other class came back with an error. only my base class. Here is the base class:
#include <iostream> #include <string> using namespace std; class Bankaccount {
[Code] .....
The error I'm getting is saying:
error C2143: syntax error : missing ';' before 'using' Where is there anything needing a semicolon before using?
'Bankaccount' : 'class' type redefinition see declaration of 'Bankaccount'
Is it saying this because I don't have any private class members?
'Bankaccount' : base class undefined
But it is defined.
What is the issue with this class? And how can I get it to compile and run?