C++ :: Design Class That Can Be Used That Can Represent A Parabola

Apr 24, 2013

The program is supposed to design a class that can be used that can represent a parabola.

Code:

#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <cstring>

using namespace std;
class Parabola {
public:
Parabola( double, double, double );

[Code] .....

View 3 Replies


ADVERTISEMENT

C++ :: Program That Will Represent Axis-aligned Right Triangle In X-y Plane As A Class

Apr 10, 2013

I am having trouble of exactly how "class" works. I dont know what the difference between set and get is. I have this code:

#include <iostream>
#include <cmath>
using namespace std;
class Point {
private:
double px;
double py;

[Code] .....

How to get void Triangle::setBottomLeftX(const double x) to work.

Implement the get and set member functions for the class Triangle. Use the appropriate class attributes of the class Triangle.

a. The location of the bottom left vertex is stored in the member attribute blPoint.
b. The top left vertex can be computed from blPoint and the height.
c. The bottom right vertex can be computed from blPoint and the length.

View 19 Replies View Related

C++ :: How To Design Optimal Style Class

Jun 8, 2014

I want to write a command line parsing library that is very flexible in terms of parsing style but I'm not able to design a mechanism that satisfies this requirements.

Generally i want to have a class that contains all the necessary information about how the command line has to be parsed.

Code:
// draft
class style {
public:
enum class type { // the basic style type

[Code] ....

Need completing the draft shown above, because for every basic style type there is an own set of extensions that applies only to this one specific style type.

Code:
// how a style object should be created
style parsing_style(style::type::posix, style::extension::gnu|style::extension::subcommand);

How to design the class. (using c++11 features like std::enable_if is fine)

View 10 Replies View Related

C++ :: How To Design A Smart Pointer Class

Nov 11, 2014

smart pointer class is the one that take in charge of release allocated resource when itself destroyed.

recently,i want design a smart pointer class, it take in charge of release resource allocated by new or new[].

my problem how to design destructor, you should determine the pointer ptr is pointer an array or a single object.

the structure of this smart point class may be:

template<class T>;
class smart_pointer{
public:
smart_pointer(T* p):ptr(p){};
~smart_pointer(){

[Code] ......

View 6 Replies View Related

C# :: Running A Class At Design Time

Aug 7, 2014

I have a Class called 'DataManager' which contains a list of my 'DataItem' objects (this are created by an XML file).

I have also created some custom controls which, among other things, has a property to link it to a "DataItem" object.

My question is, is it possible to create an instance of my DataManager class at design time (which runs all the code as it would at run time to create all the DataItems from the XML)?

I want to do this so that I can update my DataItem property in my custom controls to use a UITypeEditor which then allows me to link to a DataItem at design time.

View 4 Replies View Related

C++ :: State Design Pattern - Calling A Class Member

Oct 17, 2013

In the following code example of the State Design Pattern, in the main code at the bottom it defines an instance of class Machine, and then calls Machine::off;. Why doesn't it instead call fsm.off;?

Machine fsm;

Machine::off;

Then I tried imitating that by adding a class Abba, and then doing:

Abba a;
Abba::DoStuff();

but that didn't work. Why?

Full code example:

// StatePattern.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;
class Machine {
class State *current;

[Code] ....

View 3 Replies View Related

C++ :: Design A Class To Store Measurements - Unresolved Externals Error

Jul 8, 2013

Assignment: Design a class to store measurements. The class should have two data items, feet and inches, both integers. The class must make sure that the number of inches never gets below zero or above 11. If inches is outside that range, adjust feet accordingly. (Yes this means feet might be a negative number.)

Create a default constructor and one which receives one integer, a number of inches.

Overload the following operators: addition, subtraction, equality, inequality, incrementation (both pre and post) (should add one to inches), and output (in the form of: F’I”)

Code:
#include <iostream>
using namespace std;
class measurements {

private:
int inches;
double feet;

[Code] ....

I am getting a LNK2019 error and an LNK1120 errors:

Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

Error 2 error LNK1120: 1 unresolved externals

View 3 Replies View Related

C Sharp :: How To Design / Write Global Config Class That Can Be Inherited

Jan 31, 2013

I need to create a GlobalConfig class. But I want to derive from it in another class.

Here's an example:

public class BaseConfig {
 public string GlobalPath {get; set;}
}  
public class ConfigA :  BaseConfig  {
 public string pathA {get; set;}
}  
public class ConfigB :  ConfigA  {
 public string pathB {get; set;}
}

The idea behind is that I don't want to write the code multiple times and what's more important in class ConfigA I want to set GlobalPath and have access to it in ConfigB.

In other word I want class ConfigB to have a property GlobalPath which was set in class ConfigA.

To clarify I want to have only one object of Config in memory.

When I set BaseConf.GlobalPath to 'A', I want to access it from ConfigB.GlobalPath and also get 'A'.

I always design GlobalConfig as a static class, but static classes can't be inherited. So I tried to implement Singleton Pattern, but ConfigA can't find constructor of class BaseConfig because it's private.

View 1 Replies View Related

C++ :: Design Image Class Which Should Work With Various Data Types (Multidimensional)

Dec 2, 2013

I have been thinking about this all day and I am yet to come up with a good solution. So, I need to design an image class which should work with various data types (int, float, double etc.) and can also be multidimensional (2, 3, 4, 5). So, what I did was generate a template image class as follows:

Code:
template<typename T, int dimensions=3>
class Image {
private:
T * data;
};

Anyway, now I have various image formats that I want to support, so the easy thing to do is create a Factory sort of object which will call eventually generate the correct image.

So I want to create various image classes called ImageType1, ImageType2 etc. which will take the input image and generate the correct Image object. However, I do not want these objects to be templated because they need to be passed from functions and be used in a generic way.

So, at run time I will need to be able to do this…

Code:
class ImageType {
public:
ImageType() {
PolymorphicImage * image = new Image<float, 3>();
}
private:
PolymorphicImage * image;
};

So, I want my ImageType classes to contain the Image object and be able to generate it with the right template arguments at run time. Is there any way to do this without having multiple specialised definitions for ImageType?

View 2 Replies View Related

C/C++ :: Design / Implement And Test A Class That Represents Time In Minutes And Seconds

Nov 29, 2014

Design, implement, and test a class that represents an amount of time in minutes and seconds. The class should provide a constructor that sets the time to a specified number of minutes and seconds. The default constructor should create an object for a time of zero minutes and zero seconds. The class should provide observers that return the minutes and the seconds separately, and an observer that returns the total time in seconds (minutes x 60 + seconds). Boolean comparison observers should be provided that test whether two times are equal, one time is greater than the other, or one time is less than the other. (You may use RelationType and function ComparedTo if you choose). A function should be provided that adds one time to another, and another function that subtracts one time from another. The class should not allow negative times (subtraction of more time than is currently stored should result in a time of 0:00). This class should be immutable.

this is one of my main errors: Error1error C2653: 'Time' : is not a class or namespace namec:userskdesktop
oane statecisp 1610visual studioschapter 12 assignmentchapter 12 assignmentchapter 12 assignment.cpp131Chapter 12 Assignment

//The implementation file ImplFileTimeClassAsgnt.cpp:

#include "Time.h"
#include <iostream>
using namespace std;
Time::Time() {
mins = 0;
secs = 0;

[Code] ....

View 2 Replies View Related

Visual C++ :: Design Class Objects To Support Outlining Of Collection Of Items

Sep 9, 2013

I am struggling with how to efficiently design my class objects to support the outlining of a collection of items. The collection would be sorted but would also have the ability to indent and outdent individual items representing a Parent and Child relationship (see attached).

An item could indent up to 5 levels deep. A summary level would be considered a Parent while items below the summary level would be consider as children.

View 6 Replies View Related

C/C++ :: Object Represent A Value And Add / Remove Cart?

Sep 25, 2013

im working on Book Ordering system and i having trouble how to make the system recognize different price values when i add different books into it, also how to make the system to be able to add/remove cart?

View 12 Replies View Related

C++ :: Program To Read Image (Later Represent By Array 3D)

May 1, 2013

I will make a program to read the image in C++. And later, the image will represent by array 3D, which (x,y) represent the spatial coordinate of (height*weight) image (pixel) and z represent the intesity of those image (0-255).

In matlab, the code for do that is --> imread('image.jpg')

How can I do that in C++?

View 2 Replies View Related

C++ :: Two Player Tic Tac Toe Game - Use Enums When Possible To Represent Values

Apr 19, 2013

Here is the code I have written so far. My problem is that when the second user enters its position the last user's position is wiped of the board. I want to know how I can hold that position and keep doing so until the game is finished. I thought that calling the previous function would do that (and you can see where I have put that into a comment) but it doesn't.

Code:
#include <iostream> //includes header file
using namespace std;
//function prototypes
void printLeftUpper(int i, int j);
void printMiddleUpper(int i, int j);

[Code] ....

View 1 Replies View Related

C++ :: Obtaining Pointers To Represent Each Branch In Hierarchy?

Aug 24, 2014

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:

#include <iostream>
#include <string>
#include <map>

[Code].....

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().

View 7 Replies View Related

C# :: How To Represent A Table That Contains Dynamic Content In Header

Jun 2, 2014

I've attached an image that shows a basic table with dynamic content in the header.

Initially, I thought about using a datagrid. However, I can't use a datagrid because of the format of my data visually. The DataGrid would not allow me to have static and dynamic data inside my column headers.

You see anything I am displaying in brackets, {}, are being updated with results after I process some data in the backend. After the data analysis is done, the results are displayed based on an algorithm.

So, let's say for control1, for each family, it would indicate whether the data passed or failed. Then, in the rows themselves, it would update with choice 1 or choice 2 depending on the data generated.

So, the data that is in brackets shows properties being updated. I'm not sure what UserControl I can use to accommodate this kind of display.

View 13 Replies View Related

C++ :: How To Create Member Function To Represent Embedded Task

Jun 17, 2014

The following code is an example of how task are created with micro cos III in c. I am trying to figure how to create similliar code in C++. My problem is how do I instantiate objects and how to use member functions to represent task. Within the create task routine the address of function is passed as argument. How do I do this in C++? Will I need more than one class? New to embedded C++.

/*!
* @brief LED Flasher Task
*/
void
led5_task (void * p_arg)
{
OS_ERR err;
(void)p_arg; // NOTE: Silence compiler warning about unused param.

[Code]...

View 2 Replies View Related

C++ :: Stack Function Is Supposed To Represent Scope Of Program

Dec 5, 2014

I am trying to make an interpreter. This stack function is supposed to represent the scope of the program, meaning scope of the variables. The START represents a new scope, and FINISH represents the current scope closing. I am trying to do a recursive function in which the stack is updated with each recursive call, which represent a new scope for each call.After i enter a new scope and the scope ends, my program prematurely terminates.

void stack(ifstream& file,Hash& Table) {
string line;
getline(file,line);
int i=0;

[code].....

View 2 Replies View Related

C++ :: Represent Each Inputted Amount Of Rainfall Into A Graph With Loops?

Mar 15, 2013

I need to represent each inputted amount of rainfall into a graph like this.. how would I do this with loops?

View 5 Replies View Related

C++ ::  Tree Data Structure To Represent Category And Subcategory Of Products

Jan 15, 2015

Given a product category and sub­category representation:

a. Come up with a tree data structure to minimally (in terms of storage) represent this
b. Write a program to convert the given representation (shown in example below) to this
c. Write a function to output the tree structure in a nice human readable format

Note:
a. There can be any number of levels of depth
b. Rows may be repeated in input, but need to feature only once in the final tree.

Example category list (read this input from a file):

everything else|office supplies
electronics|video games
electronics|video games|accessories
electronics|video games|accessories|headsets
electronics|video games|accessories|flight controls
electronics|video games|accessories|joysticks

View 5 Replies View Related

C++ :: Design A Program For A Machine?

Jul 10, 2014

My need is that i need to design a program for a machine. The machine takes "x"qty of load, refines 30% of it and sends back the 70% to the initial position. after how many times, does the qty of the load refined will be equal to the initial load and how many times does it need tot be refined?

View 1 Replies View Related

C++ :: How To Write Algorithm / Design

Nov 16, 2013

How to write Algorithm / Design

View 7 Replies View Related

C# :: Inheritance In WinForm Design

Feb 23, 2014

I have two Form Employee and Instructor, here Employee is super class of instructor.

public class Instructor: Employee
{
//Instructor class
}

I am able to access all property of Employee inside instructor class but with these some textbox and button design inside Employee design is also getting inherited inside Instructor design and i don want this and i want to maintain the parent-child relationship between Employee and Instructor.

View 11 Replies View Related

C++ :: Yahoo Finance API Design Code

Apr 22, 2014

I get a bunch of broken links and nearly nothing when I search for how to hook up Yahoo Finance with C++ api.

Is there code for Yahoo Api or a search feature?

I need to look up stock tickers, volume, and closing price.

View 17 Replies View Related

C++ :: Selecting Design Pattern For Validation

Jan 21, 2015

I am looking into some design pattern which works for validation.

I thought about using strategy but not sure whether its correct or not

View 3 Replies View Related

C++ :: Design Pattern For Function Operation

Dec 11, 2014

Any design pattern allows to describe operation like the following.

MyFunctionObject f;
//Init f...
MyFunctionObject g;
//Init g...
MyFunctionObject h = f(g) + g;

[Code] .....

I'm interested in design pattern which permits to model this kind of structure, if there's of course...

View 7 Replies View Related







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