C++ :: How To Change Hierarchy Without Passing Root Element
Aug 6, 2013
I got a mesh which has an edge with a specific transformation (translation + orientation). When this configuration / transformation is changed, its neighbours are to be updated. This structure is kept inside a tree so that when a root "frame" is passed to a method like UpdateHierachy, the mesh will recursively update itself.
If, I don't pass this method the root element, which is in my case, how do I change the rest of the structure? The reason to do this is because I want to say move the door, the windows and furniture will move along with it.
I have an application which is used for calibration for electrical components. Here I want to set a rootpath for this application. I did some research and I found out that I can get the rootpath of the application (that is where the exe is stored) But what I am really looking for is once I start the application the root path should be what I assign. For instance currently the root path is "C:UsersPublicDocumentsABC.ToolsProjects" but I would like the root path to be "E:New ABC" Is this possible? I wrote some code where I call the exe of the application and it opens the file in a folder that I specify :
#include <stdio.h> void define (int integer, int IntArr[0], int *IntP); int main(void) {int integer = 0, IntArr[1] = {0}, IntP = 0; define(integer, IntArr, &IntP);
[Code]...
Why does the integer with array change after passing trough the function and the normal integer doesn't? (I know why the normal one doesn't, but I dont get the array one)
How do we design a container of objects all of which belong to some subclass which directly/indirectly inherits from a given parent class? Moreover, I would like to have functions that enable me to pick only objects of a certain class type from the container.
For example if the parent class is A and I have a hierarchy of classes that derive from it, we must have a container that can contain any class that exists in this hierarchy. Also, get_B() must be able to let me examine only those objects in this container that inherit (directly/indirectly) from class B (class B exists in the hierarchy rooted at A).
Preferably, we would like to avoid downcasting. Or even explicit typechecking of any sort.
I have been given a HW to write code for a payroll system. The base class would be Employee. There are four types of employees.
1 - Salaried (fixed salary, no matter the hours) 2 - Hourly (overtime [>40 hours] pays time and half) 3 - Commissioned (paid percentage of sales) 4 - Base-plus-commissioned (base salary + percentage of sales)
Also add a private data member birthDate (a Date object) and departmentCode, an int to class Employee.
1 - Is the following hierarchy that I'm visualizing right? Or is a change needed?
Here is the link: [URL] ....
2 - In hourly, what does in round brackets mean? What is meant by "pays time and half"?
3 - In base-plus-commissioned, is it required to take "base salary" from user or I just get salary from the salaried employee?
My program has a large version of this, where every leaf class is singleton, and pointers of the base class to represent each possible path are stored in a map during compile time. I have it working as follows:
But System::initializePrototypes() is constructing the map manually, and I want to use recursion somehow, because my hierarchy is much bigger than this. It's also easy to miss a path doing it the above way, and when new classes are added to the hierarchy, it will be a nightmare to update the map. So the ideal solution is recursion constructing the map perfectly--and when new classes are introduced, nothing needs to be added to System::initializePrototypes().
So I have linked list and function which deletes element if next element is bigger, so my code is working but its not working with first element, in the comment I have wrote code which I would code for checking that first element, but when ever I check it is blowing up all program.
#include <iostream> using namespace std; struct llist { int x; llist *next;
I have a global list that contains smaller lists of char arrays. I have an issue where when I'm reading back the inner lists the last element of one list seems to point to first element of the next.
So my data looks like the below (values separated by commas with the pairs separated by tabs. The last pair in a line is the same as the first). When I read the first list back instead of seeing "456.678,678.98" as the last element in the list. I see "435.67,234.98" twice: at the end of the first list and start of the other. I have debugged when the list is populated and can see the correct values going in so I can't figure what's happening.
obstacle_list = op_prg_list_create(); while (fgets(line, sizeof(line), obstaclePositions_traj_file) ) { token = strtok(line, " "); //Pull the string apart into tokens using the
I have an std list of type double.. and the list is always guaranteed to have just 2 elements. I need to get the value of element 2 minus element 1. What is the least amount of code to accomplish that?
I tried this:
Code: list<double> dList; dList.push_back(1.0); dList.push_back(2.0); list<double>::iterator iter = dList.begin(); list<double>::iterator iter2 = dList.end(); double result = *iter2 - *iter;
My coin/money change code works when there can be an exact change each time, i.e. when the 1 cent option is available. However, when the change options are only $10, $5, $1, 25 cents and 10 cents, it does not give me what I want for instance, I wanted to get change for $237.80, I was expecting to get:
23 10's, one 5, two 1's and 8 dimes. However, the code below is giving me 23 10's, one 5, two 1's and 3 quarters (there is no option left for the 5 remaining cents).how to fix it?
Code: #include<iostream> #include<algorithm> #include<vector> using namespace std; void change(double cents, int a[]); int main() { double Dollars; double cents;
i have written a function that gives me the square root of a number. Yes i know there is already a function in <cmath> that gives square roots but i thought it would be pretty challenging (and therefore fun) to try writing one on my own. I wrote my code while i was in school, listening to my Irish teacher ramble on and on about useless shit, so it's probably not the best possible way of finding the square root of a number.
Lets say for example I have a BST that is sorted by char names, using strcmp. IF greater than 0 go right else go left.
I.E (this is just an example, they are not inserted correctly)
cat / dog buffalo / / fish mouse zebra snake
I wanted to make a copy of this BST IF the length of the nodes are greater than the root, how would I approach this? I kinda started on this but I'm not sure if I'm making this more difficult than it should be.
void BST::copygreater(node * root, node *& dest, int & holder) { if(!root) { dest = NULL; return; }
holder = strlen(root->name) + 1; //Don't know about this? If we do a recursive call then the value would change every call?
I got problem in binary tree code. below is my code. When i select pre, post or inorder, the .exe is not responding.. Since in my binary tree theres no roots yet.. who do i solve it? It need condition or what?
I'm trying to parse the root directory of FAT32 in order to get a dir list in the root folder.
So I need to go over all the directory entries in the root directory and parse them.
My problem is that I don't know when to stop the iteration - How to get the size of the root directory?
I noticed that there is a byte in the boot sector - the number of the entries in the root - but in FAT32 the value is always 0, So how can i get the size of the directory?
I am writing a program to find the square root of a number. I am using the Newton-Raphson method..Just to clarify a bit of the code.. fabs(1/(x+1)) < 0.001 is to check for relative error..
EXAMPLE: for user entry of 100 if the iteration process ends in 10.055 the answer will return as 10 which is correct. But it isn't doing that.
It compiles I then proceed to run it..prompts me "Enter a number to find the square root of: I type 100 then hit enter...
"The square root of 100 is -1077834936"
My first time writing a program from complete scratch.
And I know there is a sqrt() function...just wanted to write my own.
Code:
#include <stdio.h> #include <math.h> double mysqrt(double a); int main() { double a, result; printf("Enter a number to find the square root of: ");
I am trying to computed the time it takes for a projectile to hit the ground. The problem is that i need to square the input of velocity before i do the calculation. the question I have is that if it's possible to have multiple arguments inside the brackets after main.
#include <stdio.h> #include <math.h> double distance (double a, double v, double g); int square(int y); double height(double v, double a, double g); double time (double v, double a, double g); double sqrt(double num);
I want to find the root of an equation f(x) by using the secant method [URL] .....
#include <math.h> #include <iostream> using namespace std; //Define function f(x) double f(double x, double a, double b) { return sin((a*x)/(1+x*x))*atan(b*x)+atan(x);
[Code] ....
1) Do I have to keep the function f and RootFinderSMNew in different cpp files?
Add a square root function to the rational class. Have your program print the square root of any rational number. I want to find the square root for numerator and denominator separatetly. divide the answer to get decimals and convert the decimal to fractions. i got till geting the decimal but i want to convert it back to a simplified fraction
// finding greatest common factor int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); }