1,358 Posted Topics

Member Avatar for caut_baia

Unless it's more feasible for you to use a friend function (mostly for reusability), I think you would be better off incorporating your read/write directly into your class. This way, you can tell an object to write itself to the file or tell it to read its own data from …

Member Avatar for Labdabeta
0
653
Member Avatar for maikens

[QUOTE=pseudorandom21;1483629]In your example: tolower is in <cctype> and is a C function.[/QUOTE] I'm sure Narue knows that. The more important questions are: [list][*]Why do you think there is a problem? [*]Do you know why she wrote the call to it the way she did?[/list] @OP: glad you figured it out

Member Avatar for pseudorandom21
0
237
Member Avatar for sandersfm

[QUOTE][CODE]... int main () { int Score; //ret is for return :) another personal preference ... return Score; } [/CODE][/QUOTE] Unless you have a VERY GOOD reason, this is not a good "personal preference". Your main() [B]must return zero (0)[/B]. Any other return value besides zero (0) indicates some sort …

Member Avatar for sandersfm
0
155
Member Avatar for woody0114

[QUOTE][CODE]#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { char bend = '#';//#@ beginning and end char cues = '?'; int n,x,y ; cout <<"Please enter number of ?'s :"; cin >> n; cout<< bend<< endl; for(y=1;y<=n;y++) { for(x=1;x<=y;x++) { cout<< cues <<bend; } cout<< endl; …

Member Avatar for woody0114
0
126
Member Avatar for DKDeath

Since you're asking about MFC, I'm not sure I can help, but I think you should clarify something. Are you trying to create a CGI script? If not, what are you trying to create?

Member Avatar for DKDeath
0
397
Member Avatar for schrope

[QUOTE][CODE]int main(); // function main begins program execution { int main=0; int digit_one; //store digit one int digit_two; //store digit two int digit_three; //store digit three int digit_four; //store digit four[/CODE][/QUOTE]Lose the semi-colon after main() on Line 1. Having it there changes it from a function header to a function …

Member Avatar for schrope
0
145
Member Avatar for ulanda1025

[QUOTE=mcriscolo;1480050]Check out line 23 - what's that equal sign ("=") all about? Remove that and see what happens.[/QUOTE] There is substantially more going on here than just that. The problem is, the OP didn't give us the header, so we don't know how the class is declared. The errors are …

Member Avatar for Fbody
0
238
Member Avatar for atticusr5

[B]>>Does that sound about right? I just want to make sure I have the understanding locked down.[/B] It looks like you have the right idea. If you make an operator function a member of a class/struct (or a friend of the class/struct) it will have access to the data members …

Member Avatar for atticusr5
0
147
Member Avatar for lochnessmonster

Huh??? Why would you want to do that? Care to clarify your reasoning? If we have a reason, it may be easier to give you a more valuable response and/or suggest a better alternative.

Member Avatar for mike_2000_17
0
93
Member Avatar for biogig

[QUOTE][CODE]46. for(i>0;i<size;i++)[/CODE][/QUOTE] The first statement in a for loop's header must be an assignment statement, not a relational statement.

Member Avatar for biogig
0
886
Member Avatar for sdr001

Use escaped double-quote characters (\"):[CODE] << "<input class = \"btn\" name = \"calculate\" type = \"button\" VALUE=\"Shortest Path\" onClick=\"sendDataST(document.getElementById('begP').value + '\n' + document.getElementById('endP').value + '\n')\">\n" [/CODE] I've changed most of them. I think that the ones I didn't change will be okay, but it's been a while since I've written …

Member Avatar for Fbody
0
169
Member Avatar for spoonlicker

The point Narue is trying to make is that you have to actually try to do something with a function/feature/component before you can begin to understand it. It's called practice. You'll never learn anything if you don't step into the unknown once in a while. There is no magic crystal …

Member Avatar for katokato
-1
695
Member Avatar for Sundayy

[QUOTE=Sundayy;1474869]Here is my second attempt, I am now getting on line 27, an error; no match for 'operator >>' in std::cout >> "What is (X3*360):\012"'. Can you please tell me how to fix it, see my code below. Thank You CODE [CODE] //Variables: //X1 = Total Number of Seconds //X2 …

Member Avatar for peter_budo
0
446
Member Avatar for gvkumar

I believe the post directly in front of yours answers your question... Did you even read the thread before you hijacked it? [QUOTE=Banfa;1191658]From winreg.h [code] #define HKEY_CLASSES_ROOT (( HKEY ) (ULONG_PTR)((LONG)0x80000000) ) #define HKEY_CURRENT_USER (( HKEY ) (ULONG_PTR)((LONG)0x80000001) ) #define HKEY_LOCAL_MACHINE (( HKEY ) (ULONG_PTR)((LONG)0x80000002) ) #define HKEY_USERS (( HKEY …

Member Avatar for gvkumar
-2
142
Member Avatar for JaviP

"setprecision" is a stream manipulator. Most of the stream manipulators are found in [URL="http://www.cplusplus.com/reference/iostream/manipulators/"]the <iomanip> header[/URL] (which you haven't #included).

Member Avatar for Fbody
0
6K
Member Avatar for spoonlicker

As Narue explained, a struct and a class are essentially the same. The only real difference is that members of a struct default to the [B]public[/B] access level while members of a class default to the [B]private[/B] access level, unless otherwise specified in the declaration of the struct/class. In some …

Member Avatar for Narue
0
1K
Member Avatar for ntrncx

What do you mean by "summarize"? Can you provide a sample of intended output? The new version of Line 11 is an accumulator, is this your intent? Are you trying to create a column of values then display the accumulated total? If so, you'll have to move Line 11 down …

Member Avatar for ntrncx
0
149
Member Avatar for SeePlusPlus2

Chdek your spilling Nad your cAPS. (In case you can't understand that, it says "Check your spelling and your CAPS".) Does this:[CODE] inFile >> stocknam >> numshar >> buypric >> currpric; stockdata.setstockName(stocknam); stockdata.setnumShares(numchar); stockdata.setbuyPrice(buypric); stockdata.setcurrPrice(currpric);[/CODE] Match These:[CODE] string stockName; double numShares; double buyPrice; double currPrice;[/CODE]??? Answer: NO. Not only are …

Member Avatar for SeePlusPlus2
0
200
Member Avatar for jasleen12345

I noticed this:[QUOTE][CODE]else if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') vowels++;[/CODE][/QUOTE] What happens if the read character is "capital" ('A', 'E', 'I', 'O', or 'U')? This will miss those because there is a difference. I think it would be advisable for you to either create an isvowel() function or "normalize" the input by using tolower(). Either …

Member Avatar for ravenous
0
637
Member Avatar for format_c

I believe the order of operations is messing you up. Try this instead, for all 3 getlines: [CODE]getline(inventdata,(items[i]).unitPrice);[/CODE]

Member Avatar for Fbody
0
483
Member Avatar for eduard77

On Line 85 of this code, what is your reason for decrementing your iterator called "it"? If I trace your program's execution, this is the line that triggers the error. EDIT: nvm.... looked at something wrong... have to look again... <[I]section erased[/I]> EDIT 2: Due to how the scope of …

Member Avatar for mike_2000_17
0
442
Member Avatar for ronthedon
Re: Loop

Well, for starters, you need to actually create a loop. You don't have any loop structure in this code. Just remember, everything that you want to execute multiple times needs to be within the statement block controlled by the loop.[CODE] void someFunction() { //any code here will only run once …

Member Avatar for ntrncx
0
137
Member Avatar for tlwtheq

I'm not too sure how much I should say. This post reeks of a homework assignment to me. I have a feeling that this would be difficult to compile because the declaration is upside-down. Your function implementations are attempting to use member variables before they are declared, which could lead …

Member Avatar for VernonDozier
0
124
Member Avatar for JordanHam

Depending on how you get the values into your array, you could possibly use dynamic allocation, but there will be an efficiency hit because of the extra allocation and copying operations.

Member Avatar for Fbody
0
160
Member Avatar for miturian

[B]>>ios_base::binary does not actuall change how the data is written to the file[/B] That's not entirely true. While a binary file can still still be a human-readable text file, the binary file mode changes the way [B]certain characters[/B] are handled while written to and/or read from a file. It causes …

Member Avatar for miturian
0
187
Member Avatar for negneg

[B]>>Every time the compiler prints an error message during compilation, that message includes the number of the line with the problem.[/B] And, in many IDEs, you can double-click the error message to be taken to the location of the error.

Member Avatar for negneg
0
203
Member Avatar for amanoob
Member Avatar for pseudorandom21
-7
238
Member Avatar for Phinocio

>>Wouldn't it give me an error or something then? Not at compile time. It is likely to at run-time though. You were just fortunate that it didn't. All that the compiler really cares about is that the variable representing the array is a valid pointer to the proper type of …

Member Avatar for Phinocio
0
150
Member Avatar for Nandomo

[B][I]>>(Ravenous)You should use ctime instead of time.h[/I][/B] [B]>(Nandomo)Same thing it's just a matter of choice, switched it anyway.[/B] Actually, Ravenous is correct, and there is a difference. The <ctime> header is the modern (post-Standard) version of <time.h> and should always be used for modern code. It defines and uses the …

Member Avatar for ravenous
0
366
Member Avatar for wondernaet

[B]>> I can't see it, can you? [/B] I'm afraid you're not the only one. It's completely unreadable. [URL="http://www.gidnetwork.com/b-38.html"]You need to work on your formatting.[/URL] [URL="http://www.daniweb.com/forums/announcement8-3.html"]And Learn how to use code tags.[/URL]

Member Avatar for VernonDozier
0
115
Member Avatar for ckocina

The function addBigInt() is a [B]member function[/B]. As such, it only has one (1) argument, as you have written. That argument receives the [B]right-hand[/B] value from the statement. [B]The other argument is [I]the implied "this" pointer[/I] and need not be explicitly declared as part of the function[/B].

Member Avatar for ckocina
0
99
Member Avatar for Prasanna Venkat

[URL="http://www.daniweb.com/forums/announcement8-2.html"]Have you written any code yet? If so, what do you have?[/URL] It would be a good idea for you to share the relevant sections of it. From an educational standpoint, it is better [B]for you[/B] if you let us see it and discuss it with you and/or critique it. …

Member Avatar for pseudorandom21
0
186
Member Avatar for stankefa

You have 3 different instances where the copy constructor is used and 1 instance where you've used the compiler-provided assignment operator. To simplify the code a little and make it easier to read, Let's expand your main() (which by the way, regardless of program size, should have an int return …

Member Avatar for Fbody
0
198
Member Avatar for HeartBalloon

A "string literal" is a constant pointer to char. You can't assign a constant pointer to a non-constant pointer. That's a conversion that allows you to edit a constant using a "backdoor". You will need to use functions from [URL="http://www.cplusplus.com/reference/clibrary/cstring/"]the <cstring> header[/URL], such as strncpy(), to perform the assignment so …

Member Avatar for Nandomo
0
147
Member Avatar for Mayank23

Since I don't know exactly what your situation is, I'm just going to throw this out there as a possibility. You could also use an enumeration:[CODE] #include <iostream> using namespace std; enum myEnum {BASE_VAL = 0, FIRST_VALUE, SECOND_VALUE, VALUE_TEN = 10}; int main() { myEnum example(FIRST_VALUE); //select any valid member …

Member Avatar for Fbody
0
261
Member Avatar for spetro3387

If used, the arguments to main() are always going to be at least [ICODE]argc = 1 [/ICODE]and [ICODE]argv[0] = "[I]executableName[/I]"[/ICODE]. As you add more command line arguments, argc will increase and argv will get more elements. I find that it tends to help if you draw parallels between main() and …

Member Avatar for spetro3387
0
160
Member Avatar for deanus

Yes. I think you need to take another look at the wording in your book, paying particularly close attention to where the "only" is placed in the sentence and what it's attached to grammatically. Speaking in reference to static functions, it probably says something like:[list][*]"a static function does not have …

Member Avatar for deanus
0
177
Member Avatar for juanp

I can think of 2 possible issues here: [list=1][*]Unguarded headers causing multi-include errors [*]Circular definition errors that can't be resolved because of how your code is currently written. [/list] You'll have to describe the problem better and post the relevant code.

Member Avatar for Fbody
1
119
Member Avatar for Jsplinter

Your post is somewhat incomplete, making it difficult to make sense of. In and of itself, this snippet is a very bad piece of code: [list=1][*]You're trying to base a comparison on an uninitialized variable (variable 'x'). [*]You're trying to increment it when you don't even know if the value …

Member Avatar for mike_2000_17
0
130
Member Avatar for dennis.d.elston

What exactly is Car::get_gas() intended to do? It looks like you have it set up to do 2 different jobs, but you don't correctly implement/complete either job... Is it intended to add gas to the vehicle ([iCODE]void Car::get_gas(double)[/iCODE]), or is it intended to calculate fuel consumption ([iCODE]double Car::get_gas(void)[/iCODE])? Notice the …

Member Avatar for dennis.d.elston
0
1K
Member Avatar for jackmaverick1

[QUOTE=jackmaverick1;1458936]I have tried these tips and they havn't worked. You don't think it's an issue with the compiler... Here's the code [CODE] class player { public: int money; int roll; int spotID; private: char name[45]; bool banker; void getOriginalValues() { } }; player p1,p2,p3,p4,p5,p6; [/CODE] I get errors for all …

Member Avatar for Fbody
0
8K
Member Avatar for Zvjezdan23

What's "the 4018 warning"? I'm afraid there aren't many of us that know what each error/warning number means. Read the input as a string. Then, step through the string like an array of char. While stepping through the string, determine what kind of character it is and respond accordingly. For …

Member Avatar for Nick Evan
0
352
Member Avatar for indrajeet6

[QUOTE]But the output window just says: 1>------ Build started: Project: Ans7, Configuration: Debug Win32 ------ ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========[/QUOTE] A compiler wouldn't "just say" that, especially not the MS Visual Studio compiler. There must be some errors that it's reporting, please share them. …

Member Avatar for indrajeet6
0
449
Member Avatar for vanalex

[QUOTE][CODE]point::point(int x, int y) { this -> x = x; this -> y = y;}[/CODE]This is wrong. All data members are initialized before entering the constructor. For built-in types there's no guarantee it's initialized at all before entering the constructor. So what you wrote yield to undefined behaviour.[/QUOTE] Other than …

Member Avatar for vanalex
0
169
Member Avatar for JordanHam

As I understand it, the .NET libraries are Object-Oriented libraries that use a Microsoft extension to C++ called "C++/CLI" (among other things, I don't know which version is the "official" version). Technically, a statement such as "Console::WriteLine("Hello World!");" is valid C++ syntax, but it's using parts of the .NET library …

Member Avatar for JordanHam
0
133
Member Avatar for lisaroy1

There is no "perfect" definition for a class/template. What a class/template should do and/or contain is completely situational. Or do you mean something else that requires a more complete/perfect description from you?

Member Avatar for Fbody
-2
97
Member Avatar for ankit.4aug

[QUOTE][CODE]void(*fnctn)(void(*)(int *,void **),int(*)(void**,int*));[/CODE][/QUOTE]Boy, that is pretty messy, always remember, CODE blocks and whitespace are your friends. (Although I don't think any amount of whitespace will help this...) I think you may be correct, ravenous. I don't mess with them much either, but it sure looks like it's a prototype declaring …

Member Avatar for vijayan121
0
148
Member Avatar for johans22

[QUOTE=guest3;1456957]is it possible to create array of pointers and set + get its elements using a class like this?. make changes/add to the class as needed. show actual code, if possible. [CODE]class t { t::t() { } t::~t() { free(array); array = NULL; } void set_size(int s) { array = …

Member Avatar for Fbody
0
150
Member Avatar for UnseenTerror

[QUOTE="UnseenTerror"][CODE]//... 73 case 3 : 74 entrees++ ; 75 printf("Entrees:\n") ; 76 break ; //...[/CODE][/QUOTE] There's no call to entrees() here... You need to actually call the function, then store the return value. [URL="http://www.cplusplus.com/doc/tutorial/functions/"]Some info on functions.[/URL]

Member Avatar for UnseenTerror
0
205
Member Avatar for jfunchio

[QUOTE=jfunchio;1455359]I need help getting my function to overload the + operator to add a integer and a Rational object. Right now I am able to add two rational objects with my overloaded +. I made a second overloaded + function and now I am able to add an integer and …

Member Avatar for Fbody
-3
251

The End.