1,358 Posted Topics

Member Avatar for precila

Is this supposed to be a response to a question on an exam or something? It is only partially correct. If I were the instructor, I would probably take away about half of this question's points. First, this statement is only partially true: [QUOTE]The base stream class for handling input …

Member Avatar for precila
0
203
Member Avatar for lochnessmonster

I would call it neither "bad practice" nor "perfectly normal". It really depends on your situation and whether or not it warrants it. I would call it "acceptable". Ideally, your constructor would be written in such a way as to guarantee creation of a valid object. Additionally all of your …

Member Avatar for mike_2000_17
0
129
Member Avatar for yongj

I don't use linux, but just as a general debugging guideline you should always address the first error first. It is likely that the first error is the root/cause of others in the list. If you fix it successfully, it may eliminate most (if not all) of the others for …

Member Avatar for daviddoria
0
166
Member Avatar for oristt

[URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]You obviously didn't read the rules before you posted.[/URL] [URL="http://www.daniweb.com/forums/announcement8-2.html"]We can't help you with homework until you show some effort.[/URL] Here's something to get you started:[CODE] #include <iostream> using std::cout; using std::cin; using std::endl; int main() { return 0; }[/CODE]

Member Avatar for Software guy
-1
83
Member Avatar for rizzi143

No one here will re-write it for you (or at least they shouldn't). Right now you're taking the user's input and counting down. I suggest you start by first establishing a way to count up from (0) to a certain max value (10 for example). Once you figure that out, …

Member Avatar for Fbody
0
140
Member Avatar for muthu1802

When you write equations like this, you are dealing with a whole lot of undefined behavior stemming from what are sometimes called "side effects". You should [B]never[/B] write such a statement because the results are unpredictable at best.

Member Avatar for Fbody
0
93
Member Avatar for andrewjad

The code you posted is a good example of a pass "by value". What you are asking about is called a pass "by reference". There are 2 ways to accomplish this. You can do it with a pointer or you can do it with a reference. Pass by reference using …

Member Avatar for andrewjad
0
210
Member Avatar for dinners

A vector is based on a C++ system called a "template". You don't have to worry about exactly what a template is and how they work at this point, I'm sure you'll learn soon enough. In absolute simplest terms, a template allows you to define a class or function one …

Member Avatar for dinners
0
162
Member Avatar for rlhh
Member Avatar for rlhh
0
192
Member Avatar for precila

Please use [URL="http://www.daniweb.com/forums/announcement8-3.html"][B][COLOR="red"][noparse][CODE]...code tags...[/CODE][/noparse][/COLOR][/B][/URL]. They make your posted code easier to read. [B]>>(do I get this from it)[/B] Have you compiled and run it? You should be able to answer this question yourself. A couple of things I noticed: Your main() is declared void. It should be declared int and …

Member Avatar for geojia
0
194
Member Avatar for LoneStarMark

It sounds like you're trying to update some old code. What IDE are you currently using? Are you actually using Borland C++ v6 as your IDE or are you using something else?

Member Avatar for LoneStarMark
0
134
Member Avatar for glenc70

[QUOTE=Software guy;1384379]I am pretty sure that 64 bit processors are faster than 32 bit.[/QUOTE] Yes, but nearly all modern processors are at least 64-bit (both of these definitely are). Whether 64-bit processing occurs or not is dependent primarily on whether your O/S is 64-bit or not. Based on the OP's …

Member Avatar for glenc70
0
171
Member Avatar for aznlitomik3

I can see a few things: [LIST=1] [*]You are not calculating the average properly. The average of a set of values is [ICODE]totalSum / setSize[/ICODE]. Replace vals[i] with a more appropriate variable in your average calculation. [*]You should only calculate your average after you have accumulated the total sum. Move …

Member Avatar for aznlitomik3
0
288
Member Avatar for BimBam

Is this a variable declaration that uses explicit initialization? If so, try an implicit initialization:[CODE] int matrixSize = Parser::CircleElems.size();[/CODE]

Member Avatar for alwaysLearning0
0
219
Member Avatar for SVSU_Student

Please post the relevant portion of your main(). Without seeing it, all we can do is speculate. And, as jonsca said:[QUOTE=jonsca]... You may want to pass the number of elements in the array into your function instead of size. Global variables are never a good idea.[/QUOTE] Based on what you …

Member Avatar for jonsca
0
223
Member Avatar for KellieD

[B]>>You appear to create a variable called "array" (type double)[/B] From what I can see, "array" shouldn't even exist in main() anyway. It's the name of the first function parameter for SumN() and nothing more. Once the scoping of SumN() is corrected, it will be completely worthless. In main(), the …

Member Avatar for SgtMe
0
153
Member Avatar for awais1a

[URL="http://www.daniweb.com/forums/announcement8-2.html"]Not until you help yourself.[/URL] Show us your attempt first.

Member Avatar for VernonDozier
0
182
Member Avatar for Hayzam_#include
Member Avatar for jonsca
-2
178
Member Avatar for sirko

It is commonly taught that you can only have one (1) return statement in a function. This is not true, it's a technically-inaccurate educational device designed by instructors and included in many assignments to stress a different, yet marginally related, point. Usually, what is actually meant by teaching this is …

Member Avatar for Bench
0
182
Member Avatar for terabyte

Just learn it and don't worry about it. Most of the stuff in C++0x is features added to the language. Besides, if you wait for C++0x to come out before you learn it, why not wait until the next version after that comes out? Standards are constantly evolving. They have …

Member Avatar for Bench
0
147
Member Avatar for dancks

[URL="http://en.wikipedia.org/wiki/Memory_leak"]Do you know what memory leaks are?[/URL] This piece of code is full of them and is extremely dangerous. After you read the wiki article, I suggest you read about proper dynamic memory usage: [URL="http://www.cplusplus.com/doc/tutorial/dynamic/"]Dynamic Memory Tutorial.[/URL] Using those statements, it is possible to dynamically allocate arrays, but you must …

Member Avatar for Fbody
0
185
Member Avatar for SVSU_Student

[QUOTE=mike_2000_17;1390414]Welcome! I also hope you have solved the problem already, but it won't be from the help of the previous answers (sorry guys). What you need to do is loop until you hit the end of the file. The end-of-file is found by simply using "inputFile.eof()". It returns true if …

Member Avatar for Frederick2
0
375
Member Avatar for Transcendent

Care to be more specific? Your request is pretty broad/generic. Is there anything in particular you are looking for? I've read "Object Oriented Design Heuristics" by Arthur Riel. It's a good guide to designing for OOP if you're looking for something like that. It's more of a way to verify …

Member Avatar for Ancient Dragon
0
305
Member Avatar for low_coder

You'll have to explain this better, and provide some code. What you are talking about is generally not advisable. If you've designed your system correctly, you really shouldn't have to pass "this" to something. I think you need to take a closer look at your design.

Member Avatar for low_coder
0
142
Member Avatar for Tyster

[QUOTE][CODE]//Add 2 Rational numbers void Rational::addition(Rational f) { //Add numerators and denominators numerator += f.GetNumerator(); //accessor defined elsewhere in this class denominator += f.GetDenominator(); //GetNumerator defined elsewhere in this class }[/CODE][/QUOTE] There are several issues with this, but the biggest is that your class doesn't have an assignment operator defined. …

Member Avatar for mike_2000_17
0
161
Member Avatar for geryin

What do you need to find exactly? Do you need to find just 3*7, 3*8, 3*2, and 3*-3 or do you need to continue on to 7*3, 7*8, etc...? I expect you should be able to do this with 2 loops. I'm not really sure why you think you need …

Member Avatar for Lerner
0
102
Member Avatar for MrJNV

I think you need to be a little more clear about your intentions. What exactly do you mean by "I want the size to vary"? Do you want to use a vector so that the [B]number of Database objects[/B] can vary? Or do you want [B]the actual size of a …

Member Avatar for Fbody
0
99
Member Avatar for malayasthana

[QUOTE=low_coder;1384667]you should include <string>[/QUOTE] Probably your best choice. This is one thing that I really don't like about how C++ works. The type std::string is a "built-in" class, but you need to #include the <string> header in order to do anything with it. You can't even create a vector, map, …

Member Avatar for Fbody
0
146
Member Avatar for rafi85

You should be able to create some sort of boolean field, otherwise use a small integer field (like a "tinyint", or whatever your DB calls it). Once created, use a true/non-zero value as yes/checked. Your form then would have the programming to know what that value means. Obviously you need …

Member Avatar for Fbody
0
50
Member Avatar for malayasthana

I'd love to help, but there are just too many unexplained variables floating around in this clip. I can't make sense of it. This is why when posting you should: [LIST=1] [*]comment your code [*]provide a clear description of what the code is supposed to do [/LIST]

Member Avatar for Fbody
0
150
Member Avatar for mdpepper

Your function implementation doesn't match your function declaration. Implementation of overloaded constructor from Patient.cpp:[QUOTE][CODE]Patient::Patient(string pName, int pDay, int pMonth, int pYear) { name = pName; dateOfOp.setDay(pDay); dateOfOp.setMonth(pMonth); dateOfOp.setYear(pYear); }[/CODE][/QUOTE] This is how you've implemented your overloaded constructor. Have a closer look at the function's header line:[CODE]Patient::Patient(string pName, int pDay, int …

Member Avatar for mike_2000_17
0
166
Member Avatar for Anuradha Mandal

Why not look them up? [URL="http://www.cplusplus.com/reference/iostream/istream/get/"]istream::get[/URL] [URL="http://www.cplusplus.com/reference/iostream/istream/ignore/"]istream::ignore[/URL] Basically, they're both input statements, but get() lets you keep the characters extracted from the stream and ignore() doesn't.

Member Avatar for Anuradha Mandal
0
88
Member Avatar for mrar85

Hmmm... This comes across as more of a general question about function use, not a question about using functions to calculate values related to a circle. Therefore, I'm going to reply with a little different slant than is perhaps suggested by your thread title. In C++, every operator you use …

Member Avatar for mrar85
0
166
Member Avatar for qvyhnl

[QUOTE=Software guy;1384373]Hi, How about using char far *s2? Using char far will allocate 4 bytes of memory for your pointer(in simple words) which is double the size of the ordinary char pointer.[/QUOTE] Hunh?:confused: The OP isn't talking about the size of the pointer itself (which should already be either 4 …

Member Avatar for qvyhnl
0
103
Member Avatar for burcin erek

[QUOTE][CODE]*ps.Working_Hours=10;[/CODE][/QUOTE]The "dot" operator has a higher prededence than the dereference operator. You can do it this way, but you need to use parentheses to make it work properly, which tends to make it klunky.[CODE](*ps).Working_Hours = 10;[/CODE] Alternatively, you can avoid this issue completely by using the "arrow" operator to handle …

Member Avatar for burcin erek
0
178
Member Avatar for gmfreak1991

[QUOTE](1) When you post your program source code on the internet, you ARE violating the FSU honor code.[/QUOTE] I am both in industry and a college student. My school has a "Truth in Learning" policy that's similar to your "Honor Code". DaniWeb's forum rules are written and enforced in such …

Member Avatar for Fbody
0
175
Member Avatar for chibon

There might be a reason you're "Kind off dumb when it comes to c/c++". It's rather amazing how well you can learn a subject when you actually put the effort into [B]doing your own homework[/B]. [URL="http://www.daniweb.com/forums/announcement8-2.html"]Try doing it yourself, then ask for help[/URL].

Member Avatar for Fbody
-3
132
Member Avatar for centerline00

Usually a "bad_alloc" is associated with a pointer, but I don't see any in your code. My suspicions: [QUOTE][CODE]extPersonType myExt;[/CODE][/QUOTE] This declaration creates a "default" object. The problem is that you have no default constructors, you have "//commented them out". The system is not providing you a default constructor because …

Member Avatar for Fbody
0
237
Member Avatar for Vv IVIatthew vV

[QUOTE][CODE]string (PlrNameConfirm);[/CODE][/QUOTE] Why do you have parentheses in this declaration? They're really not necessary. You seem to be missing some braces. Your loop seems to work correctly, but the formatting isn't technically correct. [CODE] do { //<---I don't see this brace /*... statements ...*/ } while (condition); //<--- I also …

Member Avatar for SgtMe
0
147
Member Avatar for shakssage

[URL="http://www.cplusplus.com/doc/tutorial/control/"]Here's a link to some info about C++ control structures.[/URL] You'll find information about the C/C++-Style for loop in it.

Member Avatar for jonsca
0
163
Member Avatar for mariuam

>>can any1 help me wid diz plz!!! [URL="http://www.daniweb.com/forums/thread78223.html"]Afraid not, your post doesn't give us anything to work with...[/URL] We can't help you unless you help us understand your problem. Shouting at us about some unexplained problem in txt and subsequently barfing some code into a post doesn't do anybody any …

Member Avatar for hag++
-3
105
Member Avatar for ohsevenfiveoh

You are using the [B]int[/B] variable "t" as your temporary value when you do your swap. When you try to store a double to an int it truncates the floating point part of the number. C++ arrays start at element 0, NOT element 1. The reason your first element is …

Member Avatar for Fbody
0
610
Member Avatar for hystaspes

That will most likely be a problem in both languages. The typedef isn't complete. A typedef is similar to an "alias" in other languages. It is an alternative name for the dataType. Take a vector of integers for example:[CODE]std::vector<int> myVec;[/CODE] If you want to create an iterator for this vector, …

Member Avatar for hystaspes
0
283
Member Avatar for sadsdw

[URL="http://www.daniweb.com/forums/announcement8-2.html"]Generally, you'll get better help if you show us you've made an effort.[/URL] That lets us look at what you've done and point you in the right direction. Plus, it makes you actually learn what you're supposed to be learning.

Member Avatar for Fbody
0
119
Member Avatar for baconswife

Why not get a calculator and do the math on a piece of paper? It'll be substantially quicker than waiting for a forum reply. [B]>>I got a) 35 b)28.8 c) 24.96. Is that anywhere close?[/B] Quickly doing it in my head, I believe situation "a" is correct.

Member Avatar for arkoenig
0
133
Member Avatar for Syrne

A stringstream is an I/O stream just like ifstream, ofstream, etc. It just uses a string as the I/O medium instead of a file. You "output" to the string, then display the string. It is possible to overload the injection "<<" and extraction ">>" operators for a class to make …

Member Avatar for Syrne
0
1K
Member Avatar for burcin erek

By default, an std::string is passed to a function [B]by value[/B]. When you pass an argument to a function by value, a copy of the argument is made and stored in the parameter. Because it's a copy, any changes you make to it within the scope of the function are …

Member Avatar for Fbody
0
117
Member Avatar for M a H a

For starters[CODE]char letter[1]; ifstream file("let.txt",ios::out); file.close(); ofstream file2("let.txt",ios::in);[/CODE] The variable "letter" doesn't need to be an array, get rid of the "[1]" part. You have your file streams configured wrong. An ifstream should be configured for ios::in and an ofstream should be configured for ios::out. Also, you close your input …

Member Avatar for Fbody
0
404
Member Avatar for Mona..

[QUOTE][CODE]public static void main( String[] args )[/CODE][/QUOTE] Um..... if this is a Java question you may want to post it in [URL="http://www.daniweb.com/forums/forum9.html"]the [B]Java[/B] (not [B]C++[/B]) forums[/URL].

Member Avatar for Mona..
0
155
Member Avatar for digan

If your algorithm is implemented correctly, all you should have to do is reverse your comparison to change the sort order.

Member Avatar for Anuradha Mandal
0
2K

The End.