1,358 Posted Topics

Member Avatar for dospy

Inline functions can be finicky. As I understand it, because they don't have execution jumps they don't generally work unless they are part of the compilation unit* you are attempting to use them in. This lack of jumps makes the linker unable to find them if they're not already in …

Member Avatar for Fbody
0
2K
Member Avatar for marirs07

[QUOTE=dospy;1654718]that's not the name of the structure, it's an instance of and unnamed structure basically when you declare a structure without naming it, you are not allowed to create any instances of it, thus the only way to create and instance is by putting names(separated by commas) after the struct …

Member Avatar for marirs07
0
3K
Member Avatar for Jsplinter

:confused: I know gerard "mis-spoke", but is this supposed to be an extension to your question or am I missing something here? Did gerard answer your question sufficiently?

Member Avatar for gerard4143
0
154
Member Avatar for dospy

[QUOTE=dospy;1654700]i figured it out thx to you Narue, i appreciate your effort, now, one more last thing, is there any other way to specify the command line arguments than by running the program through the cmd followed by "$ ....."?[/QUOTE] As mentioned, you should be able to do it through …

Member Avatar for dospy
0
2K
Member Avatar for pthom35

In your code, you have an attempt at a default constructor:[CODE]fraction() // default constructor { numerator = 0; denominator =1; }[/CODE] Unfortunately, because your capitalization isn't correct, your compiler won't recognize it as your default constructor. Remember, C++ is [B]case-sensitive[/B]. This means that "fraction" is not the same name as …

Member Avatar for Fbody
0
176
Member Avatar for peter20

[QUOTE=Epicurus;1654496]Aren't you forgetting something? The arrows maybe?[/QUOTE] Aasking for rep is generally frowned upon and not a good idea (it's kind of rude actually). A post like this can net you some serious neg rep., especially if a mod or a partner gets hold of you. @OP: Assume you have …

Member Avatar for Fbody
0
335
Member Avatar for joon920721

[QUOTE=joon920721;1654563]I want to make a program that asks to enter number. The program will keep asking for entering number until the user enters -99. And when the program finishes, it will give the number of counts, max, 2nd max, min, and 2nd min. The program I made works for all …

Member Avatar for Fbody
0
3K
Member Avatar for TSaunders84

If this is only a temp to store the line from the file, use a std::string object. This way you should be able to avoid an extra vector* and do something like this:[CODE]std::string inputLine; getline(inFile, inputLine);[/CODE] Then analyze/tokenize inputLine and push the substrings into your final vector. *A std::string is …

Member Avatar for Fbody
0
139
Member Avatar for MattJones

Your Algorithm object in your Graph class needs to be a pointer, not an actual Algorithm object. For polymorphism to work properly, you need to use pointers. I also notice that your non-default Graph constructor is designed to pass your Algorithm object by value; this is not only slow, because …

Member Avatar for Fbody
0
205
Member Avatar for t2r

Do you have any experience with C++ at all? Your post seems to imply that you don't... Consider this a friendly warning: Don't jump directly into OO if you don't have any experience with C++, the OO parts of the syntax are much more complicated. Make sure you have a …

Member Avatar for t2r
0
188
Member Avatar for Triarius

I don't see any return statement but you've specified the function to have a string return. Have you tried re-specifying the function as a [B]void[/B] function so that you don't need the return statement?

Member Avatar for Triarius
0
190
Member Avatar for hujiba

[QUOTE][CODE]struct RandomChooser{ RandomChooser(){ srand( 0 ); } RandomChooser( const RandomChooser& RC ){} template< typename T > inline T Choose( const T& item_1, const T& item_2 ) { return (rand() % 2) ? item_1 : item_2; } };[/CODE]The situation is slightly complicated because you only want one call to srand once, …

Member Avatar for doug65536
0
170
Member Avatar for ambigouscase

[QUOTE=ambigouscase;1650902]I don't know how to create a program with that problem :([/QUOTE] That's a textbook lazy response right there. If you already knew how to create that program, it wouldn't have been assigned. Figure it out, we all had to at some point. First, get out a pen and pencil. …

Member Avatar for cherrymae.calma
0
185
Member Avatar for rockerjhr

This smacks of a design issue and begs a few questions: If you're not going to use it,why do you have the derived version of the function at all? What is so different about the "m2" version that you feel you need to call the "m1" version instead. Are the …

Member Avatar for Fbody
0
196
Member Avatar for supersuru

What do you think you have wrong? Your compiler is telling you the whole story. Did you even look at your code before you tried to compile it? What I can see right off the bat: [list=1][*]There are no headers #included. You can't access any library functions without including the …

Member Avatar for Fbody
0
156
Member Avatar for happygeek

Wow, I would tend to agree. Something this short on information and detail should never even have been acknowledged as a viable application. Samsung should sue/file/... for revocation of Apple's certificate on grounds of excessive generality. >>Did anyone notice that the design "patent" that apple uses against Samsung has no …

Member Avatar for Hakoo
1
2K
Member Avatar for GSLENK

You can string multiple outputs (including stream manipulators such as setw()) together:[CODE]cout << "Loan Amount: " << setw(12) << "$ " << setw(8) << L << endl ;[/CODE]

Member Avatar for Fbody
0
181
Member Avatar for maria536

[QUOTE][CODE]/************************************************************************** * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing …

Member Avatar for maria536
0
190
Member Avatar for s.tay

I think you need to provide a little more information about your intentions. Are you trying to plot just the integer part of a floating-point value (i.e. if you have 3.14, you want just the 3) or do you want to convert a value such as 3.1415 to 31,415?

Member Avatar for NathanOliver
0
452
Member Avatar for Anirudh Rb

[QUOTE=Anirudh Rb;1650272]How do I check whether the data members of two objects belonging to the same class are equal? Will the following code do or is it done in some other manner?? [CODE=C++] class Sample { int a; public: S(int x) { a = x; } int getA() { return …

Member Avatar for Fbody
0
78
Member Avatar for jigglymig

What seems to be the issue? Your output isn't formatted at all, but other than that, I can't discern what your issue may be.

Member Avatar for jigglymig
0
239
Member Avatar for Harley_Quinn

First, your "success" variable/parameter/argument: Either remove it from your program completely, because it really serves no purpose, (especially since you are passing it to your function [B]by value[/B] instead of [B]by reference[/B]) or make it more useful by actually checking it's value and reacting accordingly. Second: you can not use …

Member Avatar for Fbody
0
192
Member Avatar for rjcenteno

May I suggest viewing [URL="http://www.daniweb.com/software-development/cpp/threads/280189"]this thread[/URL]? It seems to be a discussion that is relevant to your situation. What it boils down to is creating an inheritance hierarchy that makes sense for shape analyses.

Member Avatar for rjcenteno
0
187
Member Avatar for rarment

Use the appropriate version of getline() to read the file line-by-line, reading each line into either a std::string object or a char array. Then, after you've read a line, use a loop to review each char in the read line. If the char is a digit either store it some …

Member Avatar for rarment
0
297
Member Avatar for ntrncx

Honestly, I think you're going about it the wrong way. If you adjust your thinking, I think you'll solve your dilemma. I suggest that you check to see if the counter is greater than 0, but [B]not equal to[/B] 5. That way, depending on the value produced, after each iteration …

Member Avatar for ntrncx
0
154
Member Avatar for Nastadon

The problem is that the char 'M' is not the same as the char 'm'. You have attempted to "normalize" the user's input, which is correct, but you don't have it in the correct spot. Move Line 9 to Line 13 so that the "normalization" occurs [B]after the user's input[/B]. …

Member Avatar for Taywin
0
205
Member Avatar for NoUserNameHere

What are you lost about? Are you having compilation issues or getting unexpected results? One thing that I'm noticing is that you don't have a default constructor for your "testClass" class. You are going to need one to be able to create "obj3". Also, I see that your arguments for …

Member Avatar for NoUserNameHere
0
145
Member Avatar for bearlow

It's certainly possible to put data into multi-dimensional arrays, but there is not enough information here to get a good grasp of the problem you're trying to solve. Where is the data coming from and how do you intend to use it?

Member Avatar for Fbody
0
207
Member Avatar for imcgrath1
Member Avatar for mike_2000_17
0
3K
Member Avatar for tyu1996

Generally video tutorials are pretty crappy. [URL="http://www.cplusplus.com/doc/tutorial/"]Here is one that should give you a decent starting point.[/URL] There are other, more-detailed, ones available; this should get you started though.

Member Avatar for cse.avinash
0
194
Member Avatar for valestrom

That's because "stdafx.h" is a VS-specific thing. If you open the actual file, you should see the #include statements for the standard C++ headers that you need.

Member Avatar for Fbody
0
205
Member Avatar for Netcode

I'm not real sure what I would do, I know it would be likely to involve family. I'm not too worried though; for blessed are those that endure to the end.

Member Avatar for M_alloc
-1
216
Member Avatar for kutuup

The file you are missing ("MSVCR80D.dll") is the Visual C++ [B]2008[/B] RunTime. The file that you have ("MSVCR100D.dll") is the Visual C++ [B]2010[/B] RunTime. Search Microsoft's site for "Visual C++ 2008 Redistributable". Download the correct version (x86 vs. x64) and install it. There are some service packs/updates available for it. …

Member Avatar for kutuup
0
676
Member Avatar for fullarmorzz

If your instructor/prof told you this was C++, they lied. This is C (with some errors). C code will work/compile on a C++ compiler because of how the languages are related to each other, but it's not technically C++ because of how it's written (the headers used, and no namespaces). …

Member Avatar for Onlineshade
0
132
Member Avatar for thinkingofaname

[URL="http://www.cplusplus.com/doc/tutorial/"]Otherwise, you could learn to write C++.[/URL] It's really not that difficult to learn, if you're patient.

Member Avatar for Onlineshade
0
136
Member Avatar for coolbeanbob

[QUOTE=coolbeanbob;1634007]Hello, I am trying to figure out how to get the rand() function to include 0. [CODE]int value = rand() % range + 1;[/CODE] No matter what I set range to be, the lower bound is always 1.[/QUOTE] You have the right basic idea, but you've not delineated your code …

Member Avatar for Fbody
0
177
Member Avatar for ellisrn

[QUOTE=pecet;1113312]You cant use [ICODE]int[/ICODE] for such big numbers as 100!, since [ICODE]int[/ICODE] usually can handle 32bit value. solution is google: "c++ big integer"[/QUOTE] 1.) I suggest you take a closer look at your datatype limits. A 32-bit signed integer can hold values ranging from about -2.1 billion to +2.1 billion. …

Member Avatar for Fbody
0
1K
Member Avatar for SCass2010

Do you want an integer that is 20-[B]Bytes[/B] or 20-[B]Bits[/B]? The int32 and int16 types are 32- and 16-[B]Bits[/B] respectively.

Member Avatar for Duoas
0
1K
Member Avatar for Tim.Anderson

I'm having trouble following your code for some reason; I think it may be due to the lack of comments. I noticed that your variable names aren't that great. I suspect that name/member/scope hiding is part of your problem. When you name a member function's local variables the same as …

Member Avatar for Tim.Anderson
0
113
Member Avatar for FriXionX

[QUOTE=FriXionX;1630130]Yeah just as you posted, just before I looked, I remembered about the default.. i'm such an idiot, lol.. And really? It worked before. I had that if() before, but am deciding to practice switch statements because apparently they're more widely used for larger stuff. ah well, thanks.[/QUOTE] Writing the …

Member Avatar for FriXionX
0
6K
Member Avatar for murnesty

Q. Your char array is 4-chars long. What are the elements it produces/contains? A. It produces/contains elements keydata[0] through keydata[3]. Q. Have another look at Line 18. What element are you attempting to access? A. You are attempting to access element 4, which does not exist because it is the …

Member Avatar for L7Sqr
0
2K
Member Avatar for bettybarnes

[CODE]printf("%d", b[i]);[/CODE] C++ is a super-set of C. Which makes the code valid C++ as well. If you want to use a strictly C++ construct, you'll have to use the <iostream> header instead of the <stdio.h> header (<cstdio> in c++) and use the [B]cout[/B] object:[CODE]std::cout << b[i] << std::endl;[/CODE]

Member Avatar for bettybarnes
0
101
Member Avatar for hailey.o3

You'll have to elaborate on the equations/functions you were given in your assignment before we'll have any clue about how to help you. Even then, you'll have to do some of the work yourself. We're not going to just hand you a ready-made solution to turn in to your prof. …

Member Avatar for Fbody
0
136
Member Avatar for Cross213

The size of an array (in bytes) is determined by the size of a single item in the array and the number of slots the array has. If you have an array of int that has 4 elements, the size of the array is [TEX](sizeof(int) * 4) = (4 * …

Member Avatar for Cross213
0
1K
Member Avatar for Kuroshi

[B]>>Would this effectively make 8 booleans using just 1 byte?[/B] In theory, yes. But the behavior of bit fields is implementation specific. The best way to tell for sure is to display the result of a call to sizeof(BooleanStruct). [B]>>Is there a way to use some looping in order to …

Member Avatar for Fbody
0
190
Member Avatar for r.cromwell

For starters, when dealing with money, a transaction is almost never an even-dollar amount (or whatever unit of currency you use). You should deal exclusively in floating-point data types (i.e. "float" or "double") and avoid integer data types. Second, your equation for calculating a withdrawal (Line 25) actually gives the …

Member Avatar for r.cromwell
0
363
Member Avatar for jt1008

Let me start by saying that this project seems awfully simple for a final C++ project. There are no data structures, objects, or pointers. I also don't see any includes or namespaces. Remember, main() is a function. [URL="http://www.cplusplus.com/doc/tutorial/functions/"]Do you place a semi-colon after the head of a function?[/URL] No. This:[CODE]int …

Member Avatar for Fbody
0
159
Member Avatar for ksm092

In overly simplified terms, a Reference is a simplified form of a pointer. They work similarly, but they don't have all the extra syntax, and aren't quite as powerful.

Member Avatar for Narue
0
251
Member Avatar for Martin C++

@OP: Can you provide more information about the context and/or use case of your program? It seems odd to me that you would have to do what you are proposing for what sounds like an extremely simple program...

Member Avatar for Fbody
0
4K
Member Avatar for ialuvtimos

[QUOTE=manugm_1987;1627317]How can you convert string to an string array?? Use pointers and increment the pointer to concatenate ur strings string *str1,*str2; for(;; ) if(str1++!=".") str2++=str2++ + str1++; Hope this is works[/QUOTE] There is WAAAY too much undefined behavior here. Not to mention you're de-referencing uninitialized pointers. Odds are, it won't …

Member Avatar for Fbody
0
116

The End.