I have a quick question. I need a way to represent orientation in degrees. I made a class which automatically changes negative angles into positive ones (adds 360 until >0) and makes sure they are under 360 (subtracts 360 until <360).
Now I realized I also need a class to represent angular movement, which must be in the range ]-360;360[
I don't think custom types with the unsigned keyword is a thing, but I'm just looking for a better way to do this then making two classes. Or would you just create a class which inherits from angle and overloads a few methods?
Or I could just use floats to represent rotation, because testing if an object does more than 1 turn per second isn't really required.
I am currently stuck on what I should do next in a program I am working on. These are my instructions:
Design, implement, and test a class for storing integer arrays "safely". The array should be able to hold any number of integers up to 100.
In the class header file "SafeArray.h" students must define the class and specify the constructor/destructor functions, the public methods and private variables. In the class implementation file "SafeArray.cpp" students must implement the following operations:
constructor - to initialize the object. copy constructor - to copy an object. destructor - to delete the object. set - allow the user to set a value of the array at a particular location. get - allow the user to get a value of the array at a particular location. print - print out the array. add - add the elements of one array to another. subtract - subtract the elements of one array from another.
The output of my program is suppose to look like this:
Set q1: 2, 3, 4 Print q1: 2, 3, 4
Set q2: 1, 4, -2 Print q2: 1, 4, -2
Add q2 to q1
Print q1: 3, 7, 2 Get q1 at 1: 7
Here is the code I have so far.
*main.cpp*
#include <iostream> #include "SafeArray.h" using namespace std; int main() {
I've a text file : Random.txt which comprises of Jade 12MS234 Male 18 Rocky 12MS324 Male 18 Marx 12MS632 Male 18
Now in my program i've a class class stud { char name[10]; char reg[10]; char gender[10]; int age; };
Now I've to write a code in c++, where i've to read the given data and store this into 3 objects of stud class(array of objects) ...then further i've to manipulate the above stored data. I think i'm getting error while storing...variables are showing random characters... give me the code.for this program..in C++
Im trying to make a c++ program for a school project, and i need to store the information into binary files, but I'm having some problems trying to store a class with string members, for example:
class whatever{ protected: string name; public: (List of functions) }
But if I do that, my code just dont work when I write and read a binary file, but if I change the string to char array, for example:
class whatever{ protected: char name[20]; public: (List of functions) }
It works good, so I wanted to know if there's some way to store a class wiht strings in binary files, or what am I doing wrong?
#include <list> #ifdef TICKABLE_EXPORTS //Automatically defined by MSVS #define DLL __declspec(dllexport) #else #define DLL __declspec(dllimport) #pragma comment(lib, "Tickable.lib") #endif
class DLL Tickable{
[Code] ....
error LNK2001: unresolved external symbol "private: static class std::list<class Tickable*,SKIPPED BITS> Tickable::subs" HUGE_SYMBOL_LIST PATHTickable.obj
I know with such a tiny and insignificant class the dll export seems pointless but this class is actually intended to be a .lib ONLY. But it is derived from by .dll style classes, and through inheritance this error is the exact same as what appears in the derived class, I just imagine that the cut down version would be easier to work with.
Is it possible to hold either a static variable in a dll which is of a dynamic type, OR would it be possible to reference an external variable which is static throughout the instances and this variable can be chucked away in a namespace of mine somewhere?
I suppose my only other option (if this is possible) would be to define a maximum instance number and create a standard array of pointers but this could both waste so much memory when not in use and cause problems if I need more memory.
#include <iostream> #include<fstream> int decryption(int); int multiply(int,int[][2]); using namespace std; main(){ int n; ifstream inFile; inFile.open ("out.txt");
[Code] .....
I was trying to store numbers read from a text file into 2D array but I am getting the error above.here is where the error occurs:
I have a base class Building. Then come its children classes - Commercial Building and Residential Building. The third level is composed of Apartment and House classes, both inherit from Residential Building.
I need to create an array of 20 elements that will store info about all these different types of buildings(Commercial Building,Residential Building,Apartment, House). How should I proceed?
I want to create filenames such as Query.student.1.bin and save them in an array. I have no problem when I don't include a "." between student and number "1" but as I add a "." there my code does not run. ( it does complie but crashes during the run)
for(int i = 0 ; i < SIZE ; i ++) { scanf("%d" , & selection[i]); srand((unsigned) time(&t)); draw[i] = rand() % 50; //feeling could be a problem with this line of code :::::
}
is it possible to do this. i am trying to get 6 different numbers stored into 6 elements of an array . this is the piece of the code i think there is a problem with. ie my program scans the numbers and then crashes at this point so think it could be something to do with the commented line?
For some reason the integer array, arr[100][50], declared in main is not storing the correct values when passed through the function charArrayToIntArray.
I made an output right in the function to show how the array is not keeping the proper values, although when I output the array from within the loop in the function, it shows the correct values.
here is my problem given below Input values (say 10) from user in array, if the value is even then place at even index else at odd index. Then how could i solve this problem?
I'm trying to read in a file and store it in an array that is dynamically allocated of a struct (which I'm not sure how to do), then parse each line using strtok() from string.h. The idea is to separate the lines by date, subject, time, etc.
Since the array is a dynamically allocated of typdef struct, it's sorted by the date of each struct, with an intial size of 25. But whenever the array needs to be resized, it should be doubled.
I have been dealing with this problem for quite some time, I've been assigned to develop a program that can store products' information within structures (the number of products is undefined). I thought I should use an array of structures, but I don't know how to declare it properly. This is what I thought would work:
struct product { string name; string in_stock; float sale_cost; int id; } prod [n]; //n being the undefined number of products the user will register/delete/modify
I already saw an example of array of structures, but it uses a defined number.