I am creating sets of list for rotational schedule. I read that to create a randomizer is by using Randomize() function. What i want to ask is how do you set the parameters? what function should i use?
for example:
1. there are three list of the same type.
2. the range are 1-100 and a-z. (can i use 1-100 instead of writing all of the range?)
3. i need seven of each range (example: 3, 42, 78, 11, 89, 64, 22, a, n, y, e, t, d, j) for each list.
4. the three list will be generated 52 times
5. (this is the hardest part) the range must be distributed equally first, before repeating the range. For example: if the number 4 is to be used again, it must wait for other number to be on the list. The same goes for the alphabet.
I have developed an application in C++ that creates some text files in a directory chosen by the user.
How can I ask the user set a Default Directory Path (and some other default parameters) so that she doesn't have to enter the same data in the GUI everytime the application is run.
The application has been developed using Qt Creator.
how would I pass this parameter and how/why is it not working this way? I've tried many different methods to this and I can't quite seem to figure it out.
class student { public: int id; //student ID number string name; //student’s name string university; //student’ university }; //student list is a doubly linked list of students.
[code]....
My header file.
I am honestly not sure where to start here. I would assume that it would know what to do with the varibles but it doesn't seem to want to accept them. It gives me
Error1error C2660: 'studentList::push' : function does not take 3 arguments
2IntelliSense: no suitable constructor exists to convert from "int" to "student"
In my program I created three separate return functions. Each function is labeled:
int boxes(int x, int y); int leftOver(int x, int y); double avgItemsShipped(int x, int y, int z);
Is it bad programming practice to use 'x' and 'y' in all of my functions? Should I use the this keyword inside the function? We use this often in my Java class and I know it exists in C++, but I haven't actually seen it used (or used it myself yet).
I created 3 Rectangle pointers. And later in the program, I would like to modify these existing Rectangles by calling constructors with parameters. Is this possible? I have a sense that it involves creating overload operators, but I am not sure how to do it, or if that's the correct path.
#include <iostream> #include <string> using namespace std; // Base class class Shape { protected: int width; int height;
I have class that have member variables which is also a class object that contains member variables which is also a class... so on and so on... like this
Code:
class Device { public: Device();
[Code]...
When i create a device object, i want to be able to initialize all its member variables, such _data, _value, but since Data has also a set of members need to be initialized, i also need to pass parameter like Record, Type, Test etc to Device constructor, all down to the primitives level of member variables of all its embedded classes object... the top level class constructor may need a very very long list of parameters....depending on the number of member variables each embedded class contains! I know i can break down the initialization process, but i prefer to do a one line initialization, without much objects copying etc... and i use scoped pointer where it need to be initialized just once. Is it common to code a constructor with long list of parameters??
Code:
Device::Device(double deviceValue, int countPlayers, int NumRecord, int DataType, double dataTest) { _data = QScopedPointer<Data> (new Data(NumRecord, countPlayers, dataType, dataTest)); _value = deviceValue; }
I wrote a fuction in C with the prototype 'void raisePowerOf2(int array[],int pow);'
If someone want to find the value of 2^456 ,just have to invoke this function 456 as the value for pow and int array with 2 elements :1 & -1 as the argument for the array.(There I used -1 to denote the end of the array.)
But it seems that this function doesn't give the exact answer
And I tried this from java also,with the same implementation.It produced the answer precisely .
I tried for hours, but unable to detect reasons why this code blok in C doesn't work properly
This is the code in c
Code:
#include<stdio.h> void raisePowerOf2(int array[],int pow); int main(){ int a[2]={1,-1}; raisePowerOf2(a,5); return 0; } void raisePowerOf2(int array[],int pow){
[Code]...
This is the code in java....
Code:
public class NewClass4 { void raisePowerOf2(int array[],int pow){ final int len=array.length; int store[]=new int[len+1]; int qtnt=0; for(int i=len-1;i>=0;i--){ store[i+1]=(array[i]*2)%10+qtnt; qtnt=(array[i]*2)/10;
So in this function it is already passing the array into the function but the thing is one parameter being passed into the function and if so how do I go about passing 3 arrays as parameters into the function? Also the program only asks for a user entry of hours for three different cars so why would there be a point in making two additional arrays to be passed into the function?
#include <iostream> #include <iomanip> using namespace std; //passing array into function double calculateCharges(double hours[], int HoursArrayLocation);//call function
So I was reading my book and it listed this piece of code. The first piece of code is in the book and the 2nd is just my test on the piece of code. I am curious as to why in the functions parameters there is a reference to aString. I've noticed that removing it has no affect on the outcome of the code.
Right now I am trying to make an alarm clock type program that will start on login and will go off when a certain time is reached. I also want to set a password that will prevent system use until the correct password is entered into the program's input. What functions will I need and how are they used?
I have to make a c++ program, in which with an algorithm I have to code a text from a file and write it to another file. The input should like this: "code forCoding.txt toBeWritten.txt" ; or like this: "decode toBeReadFor.txt toBeWrittenIn". I have done everything except one thig: It is says I have to be able to input parameter.
How should i write this? I read [URL] ....., but still dont get. The input of my program has to have 3 strings, so I guess argc should be 3, but I dont really get it. What should I have in my main about this parsing command line parameters?
I have changed my const global int NUMLABS to a non constant variable so that the user can decide how many labs to input. I adjusted the parameters of each function to add NUMLABS becuase the variable is no longer constant. But now main() returns 0 right after the user chooses how many stations to put in each lab. I am having difficulty understanding these dynamically allocated arrays.
This program uses dynamic arrays to store login information for four labs. Each of the four labs is referenced by the labs[] array which is indexed from 0-3. A pointer in the labs[] array then references a dynamic array that is of size for however many computers are in that lab.
Written by: Luca Del Signore Last modified on: October 3rd Known bugs: N/A *********************************************************************/ #include <iostream> #include <cstdlib> using namespace std;
So I'm writing a data structure from scratch as part of a university assignment in c++, and I have to write an iterator for it. The problem involves comparison between constant iterators and normal iterators, and I'm going about it in this way: I wrote a constructor of normal iterator which takes a const iterator as its only parameter, hoping that the comparison operator between two normal iterators will be enough:
btree<int> bl(5);//the data structure auto iter = bl.begin(); iter != bl.cend(); //trying to compare iterator with const iterator
but apparently this is wrong, since the compiler tells me something along the line of "no function 'operator!=' which takes ......" It seems the constructor is alright, since the following works:
btree<int>::iterator i(bl.cend());
Am I getting something fundamentally wrong about it? How is this functionality actually implemented in C++ library containers like vector?
I am creating code for a group project in my class. All my group members made a header file with an object in it with their functions. One of the functions in my partner's code uses a data member of mine in the function, so she has the function parameter a object of my object. (This isn't the code but for example)
class B { friend class A; void displayAthing(A object) { cout<<object.thing<<endl; }
I have this when I call the function in the cpp file
int main() { A object; B b; b.displayAthing(object); return 0; }
However, when I compile, it gives me an error that the function does not take 1 arguments.
If someone want to find the value of 2^456 ,just have to invoke this function 456 as the value for pow and int array with 2 elements :1 & -1 as the argument for the array.(There I used -1 to denote the end of the array.)
But it seems that this function doesn't give the exact answer
And I tried this from java also,with the same implementation.It produced the answer precisely .
I tried for hours, but unable to detect reasons why this code blok in C doesn't work properly .
This is the code in c
#include<stdio.h> void raisePowerOf2(int array[],int pow); int main(){ int a[2]={1,-1}; raisePowerOf2(a,5); return 0; } void raisePowerOf2(int array[],int pow){
In the following example, SET_DARKENING_PARAMETERS_0 is a fairly simple macro which accepts 9 parameters. The first one is called driver and the other 8 are all ints. Basically, the 8 x ints get assigned to the first 8 elements of an array which is owned by driver. I can call the macro successfully if I do this:-
But the two combined macros won't compile with VC8. Basically, I get warning #C4003 (not enough parameters for macro 'SET_DARKENING_PARAMETERS_0') followed by a load of syntax errors. However, the code (allegedly) compiles with gcc.
I'm wondering if macro CONFIG_OPTION_DARKENING_PARAMETERS might be getting truncated to just 500, (with the following parameters getting ignored)?
I noticed that when using variadic functions, if I pass the va_arg() as parameter to a function, the parameters get passed in reverse. Is that expected?
For example, the following code outputs Code: 1 2 2 1