C :: Dynamically Create A New Memo Structure To Hold Memorized Fib

Jun 14, 2013

I need to dynamically create a new Memo structure to hold memorized fib #'s.I have two structures:

Code:

typedef struct HugeInteger
{
//array to hold the digits of a huge integer
int *digits;
//number of digits in the huge integer
int length;
}

[code]....

am having trouble with initializing the struct inside of the new Memo, I need the digit fields to null and the length field to 0 to indicate that F[i] has not yet been memoized...I have F->digits and F->length in the for loop but this just simply doesn't work..

View 2 Replies


ADVERTISEMENT

C++ :: Create Structure To Hold Data For A Kennel

Apr 3, 2013

// This program creates a structure to hold data for a kennel

#include<iostream.h>
struct KennelList {
int dogID;
char gender;
int age;

[Code] ....

View 2 Replies View Related

C :: How To Create A Structure That Pointing To Another Different Structure

Mar 17, 2013

how I can create a structure that pointing to another different structure. And also passing structure to function.

View 3 Replies View Related

C++ :: Dynamically Create Class Objects?

Nov 3, 2013

regarding dynamic vector.

Shape2DLink.cpp
void Shape2DLink::InputSensor()
{
string shape,type;

[Code]....

So i'm actually using polyphormism for calculating the area of the cross and other shapes. so how do I actually make use of dynamically create an object this way?

do I create them in my Shape2DLink or in my individual child classes?

View 9 Replies View Related

C++ :: Create Dynamically Allocated Array And Input Some Information

Feb 25, 2013

I am having some trouble on understanding how to create a dynamically allocated array and then inputting some information in to it from a text file.

Example text file:
John Doe saving 135246978 300 0

View 1 Replies View Related

C Sharp :: How To Create Multiple Word Documents Dynamically

Sep 18, 2013

Need to create multiple word documents on the run.

My problem is its creating the last one only.

View 1 Replies View Related

C :: Create Structure That Stores Player Name And Score

Aug 8, 2013

We are told to modify this code following the instructions given within the code. It is a tictactoe program.

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

// Create a structure that stores a player's name (up to 20 characters) and score (# of wins)
// Call the struct Player

void info(void) {
printf("

[Code] ....

I've ended up with the following code, but the part about the name of the datafile is giving errors upon running the program.

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

// Create a structure that stores a player's name (up to 20 characters) and score (# of wins)
// Call the struct Player
typedef struct {

[Code] ....

View 4 Replies View Related

C/C++ :: How To Create Objects Of Same Data Structure (type)

Dec 31, 2014

well i create a State.h class

#ifndef STATE.H
#define STATE_H
class State {
public:
virtual void handle_action() = 0;
virtual void update() = 0;
virtual void render() = 0;
};
#endif //STATE.H

What i'm trying to create is a simple State Manager for SFML! I created another class that inherits State.

#pragma once
#include "state.h"
class FirstState : public State {
public:
FirstState();
~FirstState();
void handle_action();
void update();
void render();
};

So the question is this, each state that i have will inherit the State class. However, i wanted to perhaps add each state object into a vector array. But i'm not sure as to what data type it be? I have a state manager class that will contain the vector.

What i want to do is this, each game state will create an object that will inherit functions from the state.h class. I want to store them all in a vector array, but each object is clearly named different. My curiosity was wondering, since all those different states inherit the State.h class, can i simply create a State Object std::vector<State> *states; that will contain all those different state objects?

[URL]....

View 1 Replies View Related

C++ :: Create A Vector Using A Structure Definition As The Basis?

Jan 25, 2013

I was trying to apply what is here (as someone who writes rarely and has to relearn everything each time): [URL] ....

I'm using a header file to define the structure:

#ifndef EINSTEIN_H
#define EINSTEIN_H
#include <stdio.h>
#include <vector>
struct SizeAll{
double year;
double R;
SizeAll() { year = 0; R = 0; }

[Code] ...

This creates quite a mess. It seems that somehow the "vector" declaration isn't working as the referenced web link seems to suggest that it should. I presume that, as usual, clearing one real error will eliminate the cascade of errors the first real error produces. Why won't VC++ accept the "vector" identifier?

The error messages that follow the build attempt are:

Friedman.cpp
d:documents and settingsxxmy documentsvisual studio 2010projectsfriedmanfriedmanEinstein.h(22):
warning C4996: 'fopen': This function or variable may be unsafe.
Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

[Code] .....

View 14 Replies View Related

C++ :: How To Create Tree Data Structure With Boost

Oct 1, 2013

There seems to be lacking support for tree data structure. You have to implement it yourself?

View 2 Replies View Related

C :: Create A Structure To Store Information About Products For Sale

Apr 29, 2013

I am using Dev C++ compiler on Windows 7 and was programming a piece of code that is supposed to do the following -

Create a structure to store information about products for sale in a store. It should store information about the product name, the price, and the product number and then create an array of products called Inventory. Add five products to your inventory.

But for some reason, which is unknown to me, I always seem to get a compiler error. And this is what i have so far -

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct product{
char name[30];
int product_number;
double price;

[Code] ....

View 4 Replies View Related

C++ :: Create A Class Type Structure Using Struct Instead Of Classes

Apr 16, 2013

I am trying to create a class type structure using struct instead of classes.

Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
struct myclass {
int * array;
int nelements;

[Code] ....

Guess what I am asking is using the pointer in the first code section better or is there another way'. I don't know about making the second code work.

View 3 Replies View Related

C++ :: Use Class Structure To Create Program That Reads In Two Rational Numbers?

Nov 4, 2013

how to use a Class structure to create a program that reads in two rational numbers and adds them, subtracts, multiplies, and divides them.

View 3 Replies View Related

C++ :: SDL - Check For A Key That Is Hold Down?

Sep 13, 2013

I'm using SDL to try to create a Run and Shoot game. But I do not know how to check if a key is down while the user is HOLDING it.

I do know how to check if a key was pressed.

I have tried with the "event.key.keysym.sym" and "Uint8 *keystate = GetKeyState(NULL)" both worked to check if a key was down but I thought that the GetKeyState(); Function would even check when a key where HELD down

I want my player to move while holding down left or right arrow. So I did something like:

Code:

Uint8 *keystate = GetKeyState(NULL);
if (keystate[SDLK_RIGHT]) {
apply_surface(x++, y, player, screen);
}

How to check if a key is held down?

View 2 Replies View Related

C++ :: Hold Screen Via GUI To Console

May 15, 2013

I had a program (on console) that uses a third-part software to draw some graphs. In order to hold the graphs on the screen, I used cin.get(); and that worked.

Now I created a GUI with Qt. The code remains generally the same. The code continues to call the software to draw graphs (during drawing graphs, there is a console opened automatically). Butcin.get(); in the code cannot hold the graphs on screen anymore. The graphs appear and disappear immediately.

View 4 Replies View Related

C++ :: Variable That Can Hold String And Int In Same Time?

Feb 12, 2014

Is there a variable that can hold string and int in the same time?

If not, what can I do if I want to input data with string and int like a password for an example.

View 3 Replies View Related

C++ :: Simple Way To Hold Numbers With Lot Of Decimals

Apr 8, 2013

I have a task to hold a number like 4.0000000000000000199e+30 and, in a variable like long double (the largest of the data type) doesn't hold the whole number, holds only 4.099e+30, like that.

Any way to hold the whole number?

View 1 Replies View Related

C++ :: Hold Group Of Variables In One Variable

Oct 4, 2014

So far i know that the pointer is address value to the real variable. Pointer size depends on operation system right?

for example
32bit systems: 4byte pointers
64bit systems: 8byte pointers
128bit systems: 16byte pointers?

Anyways, there have to be an variable type in c++ what can hold a pointer.

Let's imagine that the int is the thing im looking for

struct stc1 {
char *chars;
int ints;
}
struct stc2 {
char *chars;
float floats;

[Code]....

My wish is to hold different types of variable or groups of different type of variables in one variable.

I am developing program in windows now yet it will be used in linux and who knows with what x bit systems.

View 2 Replies View Related

C/C++ :: How To Use The List Container To Hold A Class

Dec 11, 2013

How would I use the list container to hold a class?

class A {
    private : int x;
    public  : void setX(int val) { x = val; }
};  

class B {
    private : std::list<A> pdata;
    public  : void addToList();
};  

For adding, I thought of trying something like

void B::addToList() {
   A *tmp = new A;  
   if(A != 0) {
      tmp->setX(5);
      pdata.insert(tmp);
      delete tmp;
   }
}

How would I do what I'm trying to do? Or is this the wrong way to go about it? For the actual program, "B" would contain several lists of various classes.

View 2 Replies View Related

C++ :: How To Hold Pointers / References To Abstract Class

Nov 15, 2014

I have an abstract class named Terrain, and a class named RoadMap, which supposed to hold an N*N array of Terrains. But I'm not sure what type should the RoadMap class hold:

Code:
#ifndef TERRAIN_H
#define TERRAIN_H
class Terrain {

[Code] ....

I can't use an array of refernces here, so I tried this:

Code: Terrain** terrain; and then I thought this was the way to go:

Code: Terrain (*terrain)[]; But now I'm not sure.

The N*N matrix size supposed to be determined according to a given input... What type should I use there?

View 2 Replies View Related

C++ :: Declaration Of Variable To Hold A Table Of 5 Records

Aug 27, 2014

im doing a program to store name, age, time and fitness. and i need to hold a table of 5 such records.can i do this?

#include <iostream>
using namespace std;
int name1, age1, time1, fitness1;
int name2, age2, time2, fitness2;
int name3, age3, time3, fitness3;
int name4, age4, time4, fitness4;
int name5, age5, time5, fitness5;

[code].....

View 3 Replies View Related

C++ :: Template To Hold Two Dimensional Arrays - Automatic Indexing

Mar 6, 2015

For the past couple of weeks I have been working on a template to hold two-dimensional arrays. Right now I am puzzling over an indexing question.

There are many places in the template where I would like to use initializer_lists to refer to user-specified row and column ranges, particularly in member function arguments. A typical example would be a member function whose declaration would be along the lines of:

Code:
Array<Type>::some_function(std::initializer_list<int> columns, std::initializer_list<int> rows); which could get called via

Code:
arrayInstance.some_function({3:4}, {5:8});

It would be really nice to be able to use Matlab-style indexing to specify the last column, or the last row, in the Array object -- along the lines of

Code:
arrayInstance.some_function({3:4}, {5:END}); where END takes the value -1, and can be defined in Array, or somewhere else.

The way I have tackled this so far was to write myself an Indices PODS class with two elements to hold start and finish values, and a constructor-from-initializer_list that looks something like this:

Code:
Indices::Indices(std::initializer_list<int> range, int replace_value) {
int const *it = range.begin();

start = (*it == END) ? replace_value : *it ; ++it;
finish = (*it == END) ? replace_value : *it ;
...
}

So the elements of "range" give the values of Indices::start and Indices::finish -- but if either of them are entered as END by the user, they will be replaced by replace_value. (The default value of replace_value is END, so Indices::start and Indices::finish will never change if it is omitted.)

I also defined an Indices::endset(int) function to do the same thing for existing Indices objects:

Code:
Indices::endset(int replace_value) {
if (start == END) start = replace_value;
if (finish == END) finish = replace_value;
} Using Indices::endset, you can code up Array::some_function by modifying the above signature to something like

Code:
Array<Type>::some_function(Indices columns, Indices rows) {
columns.endset(this->M);
rows.endset(this->N);
...
}

This does work, and I've been able to use it in practice. However, it is klutzy. What I would really like to be able to do is have the Indices constructor handle value-replacements in "columns" and "rows", instead of needing to put calls to Indices::endset in every single Array<Type> member function that uses this approach.

The basic problem is that, when Array<Type>::some_function is called, there is no easy way of inserting Array<Type>::M and Array<Type>::N into the optional argument of the Indices constructor when "columns" and "rows" are being built.

The Indices class needs somehow to get access to these, and know which one is being used, M or N. So it needs to have some sort of deeper connection to Array<Type>, but I don't know what that connection should be.

View 2 Replies View Related

C :: Finding Positive / Negative Integers Unsigned Can Hold

Jan 25, 2013

Consider a new data type, the mikesint, which can hold 9 bits.

(a) What is the largest integer that an unsigned mikesint can hold?
(b) What is the largest positive integer that a signed mikesint can hold?
(c) What is the largest negative integer that a signed mikesint can hold?

Not sure how to determine this. I'm stuck.

View 5 Replies View Related

C++ :: Hold Vector Of Pointers In Same Class As Instances Of Those Objects?

Feb 10, 2015

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?

View 2 Replies View Related

C/C++ :: Not Able To Initialize Structure Variable Inside Main Whose Structure Defined GL

Aug 27, 2013

I am trying to run a programme implementing a function with structures in c... which is:

#include<stdio.h>
#include<conio.h>
struct store  {
        char name[20];
        float price;    
        int quantity;

[Code] .....

View 1 Replies View Related

C++ :: How To Use Structure Pointer Through A Structure Public Member Definition

Dec 7, 2014

Why doesn't this compile?

struct hi(){
void other();
}histructure;

void hi::other(){
std::cout << "Hi!" << std::endl;

[Code] ....

Makes no sense the structure is written before the structure member function is called so why is there compile errors ??...

View 3 Replies View Related







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