C++ :: Use Named Constant For The Price Of T-shirt?

Oct 5, 2014

I've go this code that I need to use a Named Constant for the price of a t-shirt.

I've already done the code from a previous lab for college and I'm not sure how to proceed.

Here is the code:

int main()
{
int tno, price=12,cost;
float discount;

[Code].....

not asking to have this done for me just a hint at where to put the Named Constant

View 2 Replies


ADVERTISEMENT

C :: Distinguish Between Character Constant And String Constant

Feb 20, 2015

Can distinguish between character constant and string constant giving examples

View 1 Replies View Related

C++ :: Named Parameter Idiom?

Sep 8, 2013

What is the "Named Parameter Idiom" in c++?

View 3 Replies View Related

C++ :: Implementation Of Named Class

Sep 12, 2014

I am trying to implement some kind of named class. It would look something like this:

class MyClass {
virtual std::string getName() = 0;
};

And now (what doesn't pass the compilation)

template <std::string NAME> class MyNamedClass {
std::string getName() { return NAME;}
};

And so every time I would like to have a class with a name, I could just do the following:

FinalClass : public MyNamedClass<"FinalClass">{};

The idea is not to have to always reimplement getName(), and just do it concisely in the declaration.

View 7 Replies View Related

C++ :: Why Cannot Dynamically Allocated Variables Be Named

Mar 25, 2013

I understand why you cant define them but why cant you name them. Or is it that you must always define them in order to name them?

Why do I have to always use a pointer???

Or is it that dynamically allocated variables on allocate space for a type to be stored and not really the variable itself so you must use a pointer???

View 1 Replies View Related

C++ :: Class Has No Member Named Function?

May 19, 2012

I keep getting an error saying ui.h:30: error: 'class BTree<Word>' has no member named 'prntInOrder'
I have no line 30 in my ui.h but if i count the lines from the .cpp as if they were attached to the .h i find the call to the BTree printInOrder()

here is my ui.h

Code:
#pragma once
#include "btree.h"
#include <fstream>
#include <iostream>
using namespace std;

[Code].....

As you can see the printInOrder() function is there so would it not see it?

Error:

Code:
ui.h: In member function 'void UI::go(std::string)':
ui.h:30: error: 'class BTree<Word>' has no member named 'printInOrder'

View 6 Replies View Related

C/C++ :: Error Header Has No Member Named Size

Dec 1, 2014

Was missing the '.s'

I'm getting this error in the 'my_free' function here "bp->s.size += p->s.ptr->s.size;" and "p->s.size += bp->s.size;" here. This doesn't make sense to me because it seems to be the correct way to access the union, and In the "my_malloc" function I use a similar call "p->s.size = nunits;" and that works fine.

// gcc -o malloctest -Wall -g -ldl main.c
// ./malloctest
#include <stdbool.h>

[Code].....

View 2 Replies View Related

C++ :: Open File Named In Unicode Characters

Sep 22, 2012

How to open a file which its name is unicode letters ? usually :

Code:
basic_ifstream<wchar_t> src("source.txt");

Work well to read file with unicode content not filename, so that example doesn't work :

Code:
basic_ifstream<wchar_t> src(L"source.txt");

Also, I have seen some alternatives for using open function but it doesn't work as well.

Code:
basic_ifstream<wchar_t> src;
src.open(L"source.txt");

I use g++ compiler.

View 3 Replies View Related

Visual C++ :: No Member Named Stoi In Namespace Std

Oct 20, 2013

I am trying to test out stoi() function found in the link below.

[URL] ....

but I got the error "No Member named stoi in namespace std." ...

View 2 Replies View Related

C++ :: Sending Dynamic Allocated 2D Array Over Named Pipe Between 2 Executable

Oct 6, 2014

Im writing a scientific software where I like to sent a 2D array (5x4) over a named pipe from a server to a client. When im sending a static array (i.e., double res[5][4];), all goes fine and it works perfect, but when I allocate a dynamic array, it provides some nonsense numbers at the client side. I feel it might be caused because I point to a memory that cannot be shared through a pipe. Am I right and how can I pass the dynamic allocated array itself over the pipe.

//Server program

// Create a pipe to send/receive data
HANDLE pipe = CreateNamedPipe(
"\.pipemy_pipe", // name of the pipe
PIPE_ACCESS_DUPLEX, // 2-way pipe -- send and read
PIPE_TYPE_BYTE, // send data as a byte stream
1, // only allow 1 instance of this pipe
0, // no outbound buffer

[Code] .....

View 2 Replies View Related

C++ :: Saving And Recovering A File Named By User-entered Parameter

Apr 7, 2013

1. How can I save a text file using a parameter which the user entered?

For example, the user enters the word "Johnny". The program will create a new text file "johnny.txt"

2. How do I search the directory for a text file after the user entered a keyword?

For example, the user enters the word "johnny". The program will search the directory and recover the text document "johnny.txt".

View 1 Replies View Related

C++ :: How To Compare Price Which Is Read From The File

Jul 6, 2014

I'm trying to compare prices which are read from the file along with other information. The input file is as shown below: The file data is something like this:

//Program to test the class listType
#include <iostream>
#include <fstream>

[Code]....

View 5 Replies View Related

C++ :: Effect On Output Of Program Of Different Numbers Input To Int Data Type Named

Mar 2, 2014

// this program gives random number output
#include <iostream>
#include <cstdlib>// contains function protype for rand
#include <iomanip>// for setw
using namespace std;

[code]....

what is the effect on output of program of different numbers input to the int data type named seed*/

View 1 Replies View Related

Visual C++ :: Creating Loop To Call In Entries From Text File Named Set

Jul 14, 2013

I am trying to create a loop to call in the entries from the text file named Set. The entries of Set.txtare :

1 2 3
2 4 5
and so on .. (64 such combinations)[/CODE]

It basically means the first combination for testing is 1 2 3 and next has to be 2 4 5 and so i have 64 such entries defined in set

My test files are located in D://data// and are named tst_data1 to tst_data64.

I created a loop for test set but its incorrect

Code:
// loop for test samples
char basefilename[] = "D://data//";
char , testFilen[160], numiChar[10];

for (int i=1; i<=64; i++) {
strcpy(basefilenme, "D://data//");
strcat(testfilename, Set[]);

[Code] .....

How can i call the Set .txt and how to define it.

View 1 Replies View Related

C :: Program That Return Value Of A Function That Returns Price

Oct 24, 2013

I'm writing a function that is to return the price of something.. What would be the most appropriate return type for this? Like in Java it would be a double...

View 6 Replies View Related

C :: Make A Live Price Chart Graph

Dec 14, 2013

The only language I know so far is C. Is there any way I can use c programming to display a live chart for a price graph including volume in different time intervals that I want to select. I want it to look like this URL....

View 2 Replies View Related

C :: Compute Total Price Of Books By A Given Author

May 7, 2013

Given a structure book defined as follows and an array lib of books

Code:
struct Book{
char title[100];
char author[100];
int price;
struct Book *nextedition;
};

struct Book lib[1000]; I'm going to write a function to compute total price of books by a given author including all books which are future editions of his book, even if the author of that future edition is NOT the specified author. title author price nextedition Book1 Author1 25 &lib[2] Book2 Author2 20 NULL Book3 Author3 30 &lib[3] Book4 Author1 35 NULL
For the example above, given the author "Author1", the function should return 90 (=25+30+35), and given the author "Author 3", the function should return 65 (=30+35).

So here's my attempt:

Code:
int totalPrice(char author[100]){
int total=0;
for (i=0; i<numbooks; i++)
if(strcmp(author, lib[i].author==0))

[Code] ....

What I'm trying to do is finding the first book in the lib of the specified author using for loop and then let the while loop do the rest. However, it seems the price is over-counted after each iteration of the for loop but I don't know how to fix it.

View 2 Replies View Related

C++ :: Calculate Bond Price Given A Certain YTM Using Class Method

Feb 22, 2015

I have been trying to calculate the bond price given a certain YTM using class method. Since the YTM and bond price are linked with each other(there is another question asking us to calculate the YTM with a given price),we put price and YTM in "private" and others variables in"public". Actually, this is the format given in my assignment.

I used "getvalue" to get the value of YTM, and used YTM in the formula of bond price calculation. However, the output of the price is infinite, while the output of price is right if I used a specific value of YTM(such as 0.05) in the formula. It means that I didn't successfully get right value of YTM.

#include <iostream>
#include <cmath>
using namespace std;
class bond{
public:
bond(){};

[Code] .....

View 1 Replies View Related

C++ ::  Sum Up Price Element In Node Of Linked List?

Sep 6, 2014

I'm trying to calculate the total price of books contained in a linked list. I've tried getTotal() function in linked list but error: no match for 'operator+=' in 'total += ptr->Node<Book>::info'| occurred. How can I access the price in the node and then calculate the total price.

Here is part of my code :

Book class
class Book {
protected :
int id;
string title;
double price;
string bookStatus;

[code]....

View 2 Replies View Related

C++ ::  sorting Ascending Order By According To Product Id / Name / Price

Jul 20, 2014

Here is my code below:

#include<fstream>
#include<iostream>
#include<stdlib.h>
#include<iomanip>
#include<string>
using namespace std;
void main() {
fstream file;
string id,name,type,price;

[code].....

I can't separate and align 4 categories neatly, how to do this solution below(the link of example for sorting Product ID in ascending order): [URL]

By the way,here is the required .txt file(test.txt): [URL]

View 4 Replies View Related

C/C++ :: Menu Won't Show Display Entire Price?

Apr 15, 2014

I am working on a drink machine simulation. I have a text file that holds the prices, names and inventory. My problem is It won't let me set my prices at 1.00 or higher. Ex: I set the price to 1.50 in the text file then when it reads the info and stores the price it only stores .50 instead of 1.50.

my code:

#include <iostream>
#include <string>
#include <fstream>

[Code].....

View 1 Replies View Related

C/C++ :: Menu Won't Show Display Entire Price

Apr 15, 2014

I am working on a drink machine simulation. I have a text file that holds the prices, names and inventory. My problem is It won't let me set my prices at 1.00 or higher. Ex: I set the price to 1.50 in the text file then when it reads the info and stores the price it only stores .50 instead of 1.50.

textfile looks like this:
Apple Juice 1.50 20
Mango Juice 1.50 20
Sprite Mix 1.90 20
Coca Cola 1.90 20

[Code].....

View 2 Replies View Related

Visual C++ :: Writing To Named Pipe Coming From A Service (session 0) Without Admin Rights

Dec 9, 2014

I'm trying to write to a named pipe created by a service, as we all know the session 0 isolation implemented in vista and forward makes this task a bit complicated.

well at this point i managed to make almost all to work but my real problem comes when i try to write on the named pipe from my GUI application with no administrator rights

If i run the GUI application with admin rights it works 100% but, I don't need that application to require the user admin rights and for security reasons i rather to leave it without admin...

so i started my research and i found that there is a way to achieve this by calling CreateNamedPipe() with a low integrity security attributes...

well how to implement but i finally made it, the problem is that it gets worse than passing null security attributes, it works with admin rights with NULL security attributes, but when i pass the low integrity security attributes it gives "access denied" even when using admin rights, so i guess im passing the wrong security attributes but how to manually create the security descriptor string.

This is the code:

Service (session0) SERVER

Code:
DWORD WINAPI PipeThreadRSVS(void* pParameter){
LPTSTR _PIPE_NAME = "\.pipeRSVHPipeIn";
bool Break=false;
char Received_Buffer[BlockSize+16];
DWORD BytesRead = 0;

[Code] ....

View 2 Replies View Related

C++ :: Display Pizza Price By Size After User Input

Mar 13, 2014

How can i write a program that allows a user to enter a size of pizza and then print the price for that size.

Example: if a user enters size ''s'' then it should display the price stored under ''s''

View 3 Replies View Related

C++ :: Program To Call Relevant Functions To Calculate Final Price

Sep 14, 2014

I want this programming to call functions choose between a customer type and call the relevent function to calculate the final price but it is not calling the functions.

#include <iostream>
using namespace std;
double amount;
double studendOrPensioner(int&choice, double &origPrice);
double OtherCustomers(int&choice,double& origPrice);

[Code]...

View 1 Replies View Related

C/C++ :: Display Unique Date And Its Related Price Found In Txt File

Apr 23, 2015

Currently i have a system that will store user input into a txt file, and have a function that will compute the daily sales of the month(Check by system date month) and display the sales of the day and the grand total of that month.

Take for example, the system date now check that the current month is Apr. Below are my current output:

20Apr2015 $11.5
20Apr2015 $15.5
22Apr2015 $4.5
25Apr2015 $4.5
28Apr2015 $4.5
20Apr2015 $4.5
Grand Total $45

But my desired result should be as below

20Apr2015 $31.5
22Apr2015 $4.5
25Apr2015 $4.5
28Apr2015 $4.5
Grand Total $45

Textfile data:

1|Bag|2|3|6|20Apr2015
2|Fruit|2.3|5|11.5|20Apr2015
3|Fruit|2.3|5|15.5|20Apr2015
4|Water|0.9|5|4.5|22Apr2015
5|Water|0.9|5|4.5|25Apr2015
6|Water|0.9|5|4.5|20Jul2015
7|Water|0.9|5|4.5|20Jul2015
8|Water|0.9|5|4.5|28Apr2015
9|Water|0.9|5|4.5|20Apr2015

Below are my code.

struct TransactionPile {
// to record item information.
string itemid;
string itemdesc;
float unitprice;
int quantity;
float totalprice;
string date;

[Code] ....

View 6 Replies View Related







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