C# :: Reorder List Depending On Dependencies?

Feb 23, 2015

I have a list of calculated fields, these fields reference other fields in their calculations. I need to create these fields beforehand as they will not exist.

I was wondering what would be the best approach for this Example List

Field1 has Field2 in the calculation
Field2 has Field4 in the calculation
Field3 has Field1 in the calculation
Field4

I'm not sure on how to approach this.

Create list in this order

Field4
Field2
Field1
Field3

View 7 Replies


ADVERTISEMENT

C++ :: Fixing Circular Dependencies With Pointers

Dec 18, 2012

I've been making a project that requires different files to have access to objects declared in other files such that circular dependencies are created. I've done some research and discovered that pointers and forward declarations should be able to fix this.

Example:

File 1 declares variable x, must edit x and y

File 2 must edit x and y, declares variable y

I know this isn't the best example, as you could probably declare x and y in the same file, but please suffice it to say that I'm unable to do that in my project.

View 10 Replies View Related

C++ :: Installing And Using Libraries (And Including Dependencies With Binaries)

Mar 4, 2013

I've worked a lot in Java and Perl and now I'm learning C++ and working on a simple e-reader (let's not get into why I'm not just using Kindle or other existing ones). This is for me and a number of friends.

At first my project will be on OS X, then Windows and Linux, and I hope to eventually use it on Android and iOS. I know that the last two will require separate GUIs, but I'm hoping the rest of the code will port easily.

Here's the problem:

I'm using Poppler to read and display PDF files. I started installing it on my iMac and it needs FontConfig, which is turning out to be a difficult install. I would not want to walk others through this or make them have to install Poppler and FontConfig (and any other libraries I find both need).

I thought I could just compile my final binaries using "-static" but I've been reading about how some libraries can't be statically linked or compiled.

Also, since I want to eventually port this to 4 other OSes (and apparently Poppler can work on those target OSes), I don't want to do something now or depend on something that will make it hard or impossible to port to other OSes later.

With that in mind, here are my questions:

1) Why is it some libraries cannot be compiled statically? How do I know if I'm dealing with one of those libraries?

2) Am I right that I could compile this program statically, and the resulting binary would include code from Poppler and FontConfig and other libraries would be included in the resulting executable binary?

3) What do I need to watch for so I can tell if using a particular library will be a problem when I need to port my program to a new OS? (Assuming, of course, that searching shows that library will compile or has been ported to that OS.)

View 7 Replies View Related

C++ :: How To Move Sprite Depending On Rotation

Jan 13, 2015

how I want my sprite movement to work: if my sprite is faced upwards and i press W, it will move up. If my sprite is faced to the right and i press W, it will go right. etc. // It doesn't work like that right now and how to do it.The sprite's rotation works fine.

if(sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) {
playerSprite.rotate(-0.08 * dt);
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::E)) {
playerSprite.rotate(0.08 * dt);

[code]....

My question is how do I move the character depending on the rotation?

Also, you might see the "if(havePlayersCollided == false) {playerSprite.move(yadiyada)}" . yes i dont need the haveplayerscollided function because it doesnt work the way I want it to. I might make a thread for it in the future, but right now I need to get the rotation movement fixed before I move onto the collision detection between players.

View 7 Replies View Related

C++ :: Loop Depending On User Input

Jul 31, 2013

I'm trying to get this program to loop the number of times I get it to input. The program compiles alright, and it does loop when I tell it too, but how do I output the grades of the multiple students?

#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
int weighted1 = 0;
int weighted2 = 0;

[Code] .....

View 12 Replies View Related

C++ :: Returning A Different Data Type Depending On A Variable?

May 2, 2013

Okay, I've been working on this Texture class that's going to be compatible with both SDL and OpenGL with the capability to create an array of textures within one class as opposed to multiple classes and such.

Now I've run into a slight issue if I want to return the value of a texture. There's two different types of textures: SDL_Texture, and a standard GLuint Texture. The problem I have is that one or the other is used, not both which is depending on whether or not the person is using OpenGL.

So when the user wants to get the texture, I need the ability to return either an SDL_Texture, or GLuint depending on whether or not OpenGL is being used.

I tried this with a template class, but it didn't work, but I'll post the code so you can see what I'm trying to do.

template <class Tex> Tex Texture::GetTexture(int TextureNumber)
{
if (TextureNumber > NumTextures || TextureNumber < 0)
return;

[Code]....

It basically just comes down to the last four lines of code. If the person is Using OpenGL return a GLuint, if the person is using SDL, return an SDL_Texture.

I would prefer to have the GetTexture function to be one function instead of two separate ones so I don't have to call a different function every time to check if I'm using SDL or OpenGL.

View 4 Replies View Related

C/C++ :: Drawing Array But Breaks Depending On Size

Jul 3, 2014

I am working on a code and first i need to initialize the array depending on the size (min size 3x3, maximum size 9x9). The initialized array will descend in order. Note that it seems like a simple code and seems to work for any size from 3x3 to 7x7, but for some reason i get a strange output in the last few rows for 8x8 and 9x9. Not sure why. The second part to my problem is the very last digit of 0. I did hard code to define it but i would like to make it a character like an underscore...what is the easy way to do this?

* Implements the Game of Fifteen (generalized to d x d).
*
* Usage: ./fifteen d
*
* whereby the board's dimensions are to be d x d,
* where d must be in [MIN,MAX]
*
* Note that usleep is obsolete, but it offers more granularity tha sleep and is simpler to use than nanosleep; `man usleep` for more.

#define _XOPEN_SOURCE 500

#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// board's minimal dimension
#define MIN 3

[Code] .....

View 14 Replies View Related

C# :: Creating Controls Which Act Differently Depending On Mode

Apr 24, 2014

I am creating a C# windows application which allows it to connect to our devices and communicate with them.

Often we need to customise this application and I have made this easier by defining its appearance and actions within an XML file which gets read in every time the application starts up. This is working really well.

However editing this XML file can be pretty laborious and often requires many cycles to get everything correct again. So I have started to create a graphical editor which allows for the XML to be generated.

The problem I am facing is that I am using the same controls in the final program and the editor so my question is how should I structure the code so that each control knows when it is in "Normal" mode and when it is in "Edit" mode?

I have started using a simple boolean flag to indicate its mode, however this now means that within every function I need to check this flag and run code appropriate to that mode, this seems a bit over the top. Is there a better/standard way this sort of this is done?

View 1 Replies View Related

C# :: Switch To End Or Start Of Array Depending On Conditions?

Apr 1, 2015

I have a seat allocation algorithm for an airplane 30 x 6 seats. The plane is 'split' front (1 - 15) and back (16 -30), right (A,B,C) and left (D,E,F). I am placing passengers in window seats front right centre (15A) first then back left centre (16F) followed by (15F) followed by (16A). This will continue for single passengers middle seats then aisle.

Another part of the algorithm is to ensure parties >2 or <=6 to sit together in an empty row, if not possible the party will be split as to not have a person in the party sitting alone firstly. i.e. 6 is 3 + 3 or 2 + 2 + 2 or 4 + 2 or 3 + 2 + 1 or 4 + 1 + 1 or 3 + 1 + 1 + 1 and so.

I have got it working for one person but seating two people is a bit more difficult. I am trying to get 15A,15B then 16E,16F then 16A,16B then 15E,15F then 16C 16D and 15C 15D.

This code only allocates passengers 15 A 15B then 15C 15D then 15E 15F

//seat allocation for two people
public bool[,] seatTwoPerson(bool[,] seatArray, int startCol, int endCol, int directionX, int startRow, int endRow, int directionY)
{ //loop through seatArray section determined by parameters
//for (int col = startCol; directionX < 0 ? col >= endCol : col < endCol; col += directionX)

[code].....

View 3 Replies View Related

C# :: Using Different Instance Of Class Depending On User Input?

Jan 13, 2015

Here's the problem I want to intialise different classes based on user input. I've tried using an IF statement but the scope of an if statement would mean the rest main program wouldn't be able to see it.

View 12 Replies View Related

C++ :: Creating Function That Outputs Either 1 Or 0 Depending On Input After Checking

Feb 18, 2014

I am trying to simplify my code by creating a function which takes an input then checks whether it is "y" or "n" then outputs either 1 or 0 depending on the input. So far this is what I have

int Choice(string choice) {
while(choice.compare("n") != 0 && choice.compare("N") != 0 && choice.compare("y") != 0 && choice.compare("Y") != 0){
cout << "Please enter a valid input either [y/n] : " << endl;
cin.clear(); cin.ignore(); cin >> choice;

[Code] ...

And I call it in the program using

cout << "Do you wish to change the hubble type of any galaxies? [y/n]" << endl;
cin >> choice;
while(Choice(choice) == 1){
....
cout << "Do you wish to change the hubble type of another galaxy? [y/n]" << endl;
cin << choice;
}

It compiles fine but displays some bizarre behaviour, I need to end the line twice in order for the program to continue and sometimes it just stops working (doesn't exit just appears to be stuck in a loop).

View 2 Replies View Related

C++ :: Calculate GPA - Divide Depending On How Many Times User Inputs A Value

Feb 27, 2014

For example, to calculate GPA, we add all the grade point of a course and divide by the number of courses we are taking. How do I create a program in such a way that when the user enters grade point for two courses, it will add the grade points for the two course and divide by 2. And if another user enters grade points for six courses, it adds the grade points and divides by 6.

View 2 Replies View Related

C++ :: Change Behaviour Of Template Class Depending On Type?

Jul 8, 2012

is there a way to have a template class respond to missing stuff in a template type ?

Code:
template <typename Type>
class MyClass
{
public:
enum { ID = Type::ID }; // revert to 1 if Type::ID doesn't exist.
};

If the Type passed to the template has an ID member (required to be an enum or a static const int), use it, if it is missing revert to a default value.

I can use this as a simplified way of configuring how MyClass works, without requiring Type to explicitely needing to define what it doesn't care about.

It needs to be resolved at compiletime, as it determines the number of elements in member array variables.

View 10 Replies View Related

C++ ::  How To Access A Specific Protected Inherited Member Depending On Class

Dec 30, 2013

I have `MainShop`(base class) then `SwordShop` and `BowShop`(derived classes) and another derived class called `Inventory`. I have a vector under protected in my base class, and when I access it from my derived classes it's okay, but each one has its own value. How can I set them all to have the same value?

//MainShop.h
#pragma once
class MainShop {
private:
//some variables
protected:
vector <string> WeaponInventory;

[code]......

Here every time I run it, it goes straight to the `else` and it displays that I do not have any items. I want to just have one vector for both my bow and Sword shops because vectors take up a lot of memory and my teacher said keep them to a minimum. So I just want one vector that takes in items from my bow class as well as my sword class, but for some reason it's acting as if I have multiple vectors, each with its own set of items.

View 3 Replies View Related

C++ :: Spaceship Game - Creating Gravity For Each Object Depending On Mass

Mar 27, 2012

I've been having trouble working on this physics engine of mine. Right now I'm having trouble adding gravity.

The game is a spaceship--which you control--flying around in space with asteroids and eventually the ability to shoot bullets. There should be a wrap on the edges of the screen and gravity for each object depending on their mass.

I'm creating a forceX and forceY for each force put onto each object, and then computing that force into a velX and velY which will determine the direction of each object and at which speed.

Where my problem arises:

Code:
//add gravity pulls to forces
for(int i = 0; i <= pushCount; i++) //add gravity pulls for each object {
for(int u = 0 ; u <= pushCount; u++) //each object should add a force for every other object {
if(i != u) {
switch(id[i])

[Code] ....

View 7 Replies View Related

C++ :: Generates Random Addition For Subtraction Depending On User Choice

Feb 17, 2012

Below is a program that generates random Addition for Subtraction problems depending on the user's choice. The user is prompted to input an answer and then it keeps your score. If you want to quit you just press zero.

Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iomanip>
#include <string>
using namespace std;
int menu();
bool addition(int &reward); // function to return truth values

[Code] ....

View 14 Replies View Related

C++ :: Output String Depending On Color Detected In A Frame Video Feed

Jul 18, 2014

what I'm trying to do is output a certain string depending on the color I see in the video feed. For right now, what I've done is threshold the feed so that everything above a certain brightness shows up as Red. Now I want to have something that says if there's any red in the feed, then I output a "1" to a text box on my user interface that's showing the feed. If there is no red, then I output a "0" to the text box.

I'm using Emgu CV C ++ with VS2010.

This is the code I have so far that isn't working correctly, it's giving me a compiler error.

cvConvertScaleAbs(frameFromCamera->Ptr.ToPointer(),frameDisplay->Ptr.ToPointer(),double(1)/16,0);
cvCvtColor(frameDisplay->Ptr.ToPointer(),frameColorDisplay->Ptr.ToPointer(),CV_GRAY2BGR);
cvThreshold(frameDisplay->Ptr.ToPointer(),maskSaturated->Ptr.ToPointer(),200,255,CV_THRESH_BINARY);

[Code] .....

and the error it's giving me

BAOTFISInterface.cpp(1010): error C2664: 'Emgu::CV::Image<TColor,TDepth> ^Emgu::CV::Image<TColor,TDepth>::InRange(Emgu::CV::Image<TColor,TDepth>
^,Emgu::CV::Image<TColor,TDepth> ^)' : cannot convert parameter 1 from 'Emgu::CV::Structure::Bgr *' to 'Emgu::CV::Image<TColor,TDepth> ^'

[Code] .....

Build FAILED.

View 1 Replies View Related

C++ :: Why Does HP / Microsoft STL List Use Same Structure For List Head And Node

Apr 23, 2013

From HP / Microsoft (Visual Studio C++) <list>:

Code:
struct _Node
{ // list node
_Genptr _Next; // successor node, or first element if head
_Genptr _Prev; // predecessor node, or last element if head
_Ty _Myval; // the stored value, unused if head
};

The stored value is wasted space for the list head. Is there any advantage to implementing list using the same structure for a list head and node?

View 6 Replies View Related

C :: Linked List / Adding Element To Beginning Of List

Dec 31, 2014

Code:

// Write a function called insertEntry() to insert a new entry into a linked list.

Have the procedure take as arguments a pointer to the list entry to be inserted (of type struct entry as defined in this chapter), and a pointer to an element in the list after which the new entry is to be inserted.

// The function dveloped in exercise 2 only inserts an element after an existing element in the list, thereby prenting you from inserting a new entry at the front of the list.

(Hint: Think about setting up a special structure to point to the beginning of the list.)

#include <stdio.h
struct entry1 {
int value;
struct entry1 *next;
};

[code]...

This is a working version of the exercise, but I don't think I'm doing what's asked. I was able to add an element to the beginning of the list using an if statement, not creating a special structure that points to the beginning of the list. How would I go about creating a special structure that points to the beginning of the list to add a new element at the beginning of the list?

View 8 Replies View Related

C# :: Display List Of MSMQ Messages In A List Box

Jan 20, 2015

I'm trying to display a list of MSMQ messages in a list box based on a drop-down list holding the environment.So i've setup the binding and i know that the list loads but nothing shows up in the list? I should be setting like a display member or something but i'm not entirely sure

const String msmqAccelaDev = "FormatName:DIRECT=OS:tcc-intsrvTCCIntegration.MSMQ.Service.Dev/TCCMessagingService.svc";
const String msmqAccelaProd = "FormatName:DIRECT=OS:tcc-intsrvTCCMSMQFail";
const String msmqAccelaTest = "FormatName:DIRECT=OS:tcc-intsrvTCCIntegration.MSMQ.Service.Test/TCCMessagingService.svc";
String currentQueue = "";
private void environmentChange()

[Code]...

View 4 Replies View Related

C++ :: Linked List Delete List?

May 30, 2013

I'm working on a linked list and was wondering how this looks to everybody else for a deleteList function.

void deleteList(Node* head)
{
Node* iterator = head;
while (iterator != 0)

[code].....

View 6 Replies View Related

C :: Insert Linked List Into Another Linked List

Jun 29, 2013

I have a linked list comprised of chars like so...

Code:

node1 - "p"
node2 - "o"
node3 - "p"

I need a function that will take in three perameters...node *replaceChar(node *head, char key, char *str)Stipulations of this function. head is the head of the list, 'key' and 'str' are guaranteed to contain alphanumeric characters only (A-Z, a-z, and 0-9). str can range from 1 to 1023 characters (inclusively). So if I call this function with these perameters..

Code:

node *head == /*the head of the list to be examined*/
char key == "p"char *str == "dog"The new list will look like this...
node1 - 'd'
node2 - 'o'
node3 - 'g'
node4 - 'o'
node5 - 'd'
node6 - 'o'
node7 - 'g'

All instances of 'p' were replaced with 'dog' I have a toString function which takes in a string and converts it to a linked list and returns the head. So assume that you can call the function on str = "dog" so...

Code:

toString(str) == /*this will return the head to the list made from the str*/

If it's unclear what my question is...I am stumped on how to write the replaceChar function the one that takes in three perameters..

View 3 Replies View Related

C :: Maintain A List

Apr 11, 2014

I want to maintain a list. which will update at regular interval. so I thought to with linked list. Earlier I have used linked list.

Code:

typedef struct
{
short nwkaddr;
unsigned char macaddress[8];
}device_t;
}

[code]....

This program is giving many errors. I tried lot to fix it. If I fix one then other bug is arising. for that I did't mentioned what bug i got.Main Issue is while (curr->next->list != NULL) this is giving segmentation fault if i add element second time

View 3 Replies View Related

C++ :: Printing Out List Using OOP

May 17, 2013

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ios;
#include "Course.h"
#include <list>

[Code] ....

The program works well, except for the fact when it prints out the list (starting at the for-loop on line 65) each line is the same as the last, like it overwrites itself every time it traverses the while(true) loop.

View 9 Replies View Related

C++ :: How To Reverse A List

Apr 10, 2013

I would like to add a new function to my class, "reverse" that would reverse the order of the list. I have added a prototype in the "public:" section of the code (see the comment with PROTOTYPE in it). Your task is to complete the implementation (see the comment with IMPLEMENTATION in it. See the main() function to see how the results should look

#include
#include
using namespace std;
class List {
public:
// Constructs an empty list
List();

[Code]....

I cant seem to get the right function to put into reverse I have tried everything Im not sure where to start!

View 4 Replies View Related

C# :: ThreadSafe Add To A List

Sep 14, 2014

I have a concurent queue holding lists, where I have one reading thread and several writing workers. My writers are adding to those lists. Now I just lock the list before I add to it -

if (transaction_calls.TryGetValue(strike, out tranlist)) {
lock (tranlist) {
tranlist.Add(tran);
}
}

Is this enough?

What my reader is about to do, is to see the list size, and reads all the data from list[i] till list[last] - I don't really care for getting the true last, meaning that if while reading list.count, another elment was added, I don't mind ignoring it.

I presume I can't use the foreach on that list, is that right?

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved