556 Posted Topics

Member Avatar for MonteM

Have you thought of just checking to see if the line is blank before tokenising it? You tokenising routine needs to be robust enough that when it hits a problem it fails in a way you can catch and deal with (normally by just ignoring the line and possibly outputting …

Member Avatar for Fbody
0
140
Member Avatar for Jean88

Yes a sting is an STL container so you can use all the usual STL algorithms on it like for instance count_if. Also you should use the functions defined in the header local, specifically is rather than the value comparisons [icode]if (paragraph >="A" && paragraph <="Z")[/icode] to check for the …

Member Avatar for Jean88
0
583
Member Avatar for Krzysztow

If this is QT then the QT documentation specifically says that you must only inherit from QObject once and QObject is a base class of QWidget. You will have to break the diamond. That might mean having a abstract class that BaseView and ButtonView both inherit from that does no …

Member Avatar for Krzysztow
0
86
Member Avatar for samanamuo

This sort of thing is not trivial because the different months have different numbers of days and February has different numbers of days in it depending on the year. The are, at least, 2 approaches [list=1]Convert the dates to the number of days past a given epoch date, 1 Jan …

Member Avatar for Banfa
0
391
Member Avatar for dondajr

Firstly if cpu utilisation is only getting to 70% there is nothing to worry about. All programs are getting all the cpu time they require with time (30% of the available time) left over. A single run of your program however only opens a single file and reads it, if …

Member Avatar for dondajr
0
147
Member Avatar for VilePlecenta

yes you separate the class definition and the member definitions like this [code] // This is normally in a header file foo.h class foo { public: void DoNothing(); }; [/code] [code] // This is normally in a separate cpp file foo.cpp void foo::DoNothing() { cfee.AddNothing(); } [/code] That way the …

Member Avatar for VilePlecenta
0
150
Member Avatar for DrueY

My (rustly) recollection from 3-4 years ago is that you need to make a class library project in your solution (I am assuming you're using visual studio) File -> New -> Project... -> Select "CLR" From Tree -> Select "Class library" from the right hand pane. Fill in the name …

Member Avatar for Banfa
0
265
Member Avatar for w0rk4holic

Interestingly if you had bothered to read the text of that page below the Java applet it tells you exactly how you can calculate the interior angle for a regular polygon and further it links boldly at the top of the page to a page about exterior angles too.

Member Avatar for w0rk4holic
0
446
Member Avatar for micmagicfly

[QUOTE=vmanes;1170775][code] for (int index = 0; index <= limit - 1; index++) [/code] is a bit awkward with the [icode] <= limit -1[/icode]. Just use the strictly less than comparison to the actual array size (or limit of valid elements), as in [code] for ( int index = 0; index …

Member Avatar for Banfa
0
96
Member Avatar for corby

You can't pass arrays. You may invoke the constructor with an array in the calling code but what gets passed is a pointer. With-in the context of a function declaration [icode]int a[][/icode] declares a pointer so [icode]IntegerSet::IntegerSet( int a[])[/icode] and [icode]IntegerSet::IntegerSet( int* a)[/icode] are equivilent. In both cases the parameter …

Member Avatar for Sodabread
0
209
Member Avatar for rkp728

[QUOTE=rkp728;1170231]I have included Common_Definitions.h in BC.h and RS.h. #ifndef Common_Definitions_h #define Common_Definitions_h #include "Common_Definitions.h" #endif [/quote]Inclusion protection preprocessor symbols like this are good, but they should go inside the file they are protecting not round every place it is included. Common_Definitions_h should have the structure [code] #ifndef Common_Definitions_h #define Common_Definitions_h …

Member Avatar for rkp728
0
3K
Member Avatar for JohnPhilipps

Like the error says you can not use the friend keyword in a managed type (manged C++ has delegates and events to get round that). Why can you just make your MoveRect function a class member?

Member Avatar for JohnPhilipps
0
469
Member Avatar for MWE_QUE

Line 26 [icode]LINKEDLIST *list = malloc(sizeof(list));[/icode] Line 34 - 35 [code]STORE *newVacantStore; newVacantStore = malloc(sizeof(newVacantStore)); newVacantStore = malloc(sizeof(newVacantStore));[/code] In both of these cases you have allocated the size of the pointer not the size of the object pointed to. Pointer is likely to be 4 bytes on a 32bit system …

Member Avatar for Banfa
0
139
Member Avatar for Iam3R

Because C is fairly lax about types and if it has an automatic conversion from the type given to the type required then it will silently do it for you. C knows how to convert float to int so it just happens. This was one of the issues fixed in …

Member Avatar for Banfa
0
147
Member Avatar for redworc53

You have given your assignment. You have given the code you have. But you have not said what the problem you are having is. Is it an issue with compiler errors? Then post the errors. Is it an issue with the program not performing as expect or desired? Then post …

Member Avatar for WaltP
0
2K
Member Avatar for honeyboynasa
Member Avatar for merse

I would question how you are using the vector to store the results. How will you differentiate between results from different functions, or worst results from different functions that take different numbers of parameters? Anyway your storage scheme aside I see 2 possible solutions. You could declare memory mutable. A …

Member Avatar for mattjbond
0
174
Member Avatar for PDB1982

When you declare a data member static there is a single copy of that data member used by all instances of the class so a.n and CDummy::n refer to the same variable. CDummy::n is incremented every time a class is constructed and decremented when the class is destroyed. So the …

Member Avatar for pecet
0
137
Member Avatar for italian

You seem to be treating as a single step, get the return value of a function, what is actually 2 steps [list=1]Return a value from a function [*]Assign that value to a variable [/list] Both have associated efficiencies as follows [b]Return a value from a function[/b] [list]Return by value - …

Member Avatar for mattjbond
0
1K
Member Avatar for Xufyan

You've missed the braces { } round the 2 lines of code that should be in the inner loop so that the printf statement is only executed once for every iteration of the outer loop.

Member Avatar for Xufyan
0
167
Member Avatar for Xufyan

[code] int number = 65; char letter = number; [/code] There are no characters in C only integers with different ranges. A character is no more than a number that is interpreted by the display sub-systems to write pixels on the screen in a forum that you recognise as a …

Member Avatar for Xufyan
0
211
Member Avatar for gnarlyskim

1. The constructor is for exactly what you have stated "initialize variables or assign dynamic memory". In this case there is no dynamic memory so it is for initialisation of member variables. If you don't implement the constructor then between constructing the object and calling read() your object will contain …

Member Avatar for gnarlyskim
0
141
Member Avatar for NathanOliver

The problem is that the parameter [icode]number[/icode] is const (constant) but you are trying to use it to call operator- which is not a const member function. [icode]number[/icode] (const Number &) can not be converted to Number * in order to make the method call in [icode]return number.operator -(*this);[/icode] and …

Member Avatar for NathanOliver
0
151
Member Avatar for sandyjain

One of the major differences is that floats get promoted to doubles when used as parameters in functions that have no declaration or in the variable parameter list of varidac functions (like printf). So printf never sees a float in the parameter list and does not need to differetiate between …

Member Avatar for Banfa
0
161
Member Avatar for xavier666

I can't explain why it is working at home, but that is the nature of undefined behaviour, however at line 48 of your code listing you free the array just before you start writing values into it.

Member Avatar for Banfa
0
652
Member Avatar for drhelp
Member Avatar for suncica2222

LPBYTE is a pointer to a BYTE. If you have allocated an array of BYTEs and pointed lpBuf at that allocated array then if you need the size of that buffer you have to store it somewhere. There is no function you can call that will return the size of …

Member Avatar for suncica2222
0
2K
Member Avatar for eXsolved
Member Avatar for balthy

Note that generating a random number between 1 and N using [icode]rand() % N + 1[/icode] for small N is a poor solution because rand() often has very poor randomness in the low order bits of its return value. [url=http://c-faq.com/lib/randrange.html]read this[/url] Rather than [icode]float pctRoll = (float) (rand() % 1000) …

Member Avatar for jephthah
0
2K
Member Avatar for Ian Morrison

You have only forward declared Vistor in this code snippet so it does compile at line 26 which requires the full declaration of visitor. Assuming this is a mistake that doesn't exists in your actual code and the the missing ; on line 33 is a typo then have you …

Member Avatar for Ian Morrison
0
96
Member Avatar for Iam3R

Just to clarify it is explicitly stated in the C standard that main if returns a value of 0 (or EXIT_SUCCESS) then the program will return a value to the system that indicates the program was successful. Note that is not necessarily 0; if the system in question does not …

Member Avatar for nezachem
0
226
Member Avatar for jephthah

Not entirely bullet proof since it will interpret my half a shopping list as a date [code] Enter Date String : 1)Fish.2)Chips.3 month : 01 date : 02 year : 2003 [/code] Verifying input involves verifying no additional garbage was input too.

Member Avatar for Dave Sinkula
0
157
Member Avatar for rpowell16
Member Avatar for stewartmatheson

That is not quite true, when the notify method is called it gets a Subject pointer to some object. You know that object can definitely not be a Subject because Subject is abstract and so can not be instantiated. You have been passed a base class (Subject) pointer to a …

Member Avatar for Banfa
0
175
Member Avatar for TimCereja

Look up the library function strtol, it will convert the digits ignoring leading blank spaces and pass a pointer back to where it finished, which will be the '/', you can then just hop over the '/' to convert the next piece of the number.

Member Avatar for TimCereja
0
362
Member Avatar for jdpjtp910

ships is declared as an array of pointers but on both lines 17 and 23 having selected the array index you dereference the array once with * and once with -> or twice in total. You can dereference a single pointer twice, loose the * on both lines. BTW I …

Member Avatar for lotrsimp12345
0
2K
Member Avatar for Fbody

I get this error from your code using gcc BitFlags.h:12: error: ISO C++ prohibits anonymous structs What compiler are you using, this is improtant of course because bitfield behaviour is very much platform dependent. Anyway after naming the struct I get a size of 4 for the struct as you …

Member Avatar for Dave Sinkula
0
378
Member Avatar for n.utiu

I have been programming for 20 years and I can say I've missed the absence of a Logical XOR operator where as I know for a fact I would miss the absence of a Bitwise XOR operator.

Member Avatar for n.utiu
0
227
Member Avatar for Tech E

With thanks to Firefox for its ability to highlight the word salary Line 27 of Income Member Function Definitions [icode] salary += s;[/icode] You add the user input value s to salary but salary has not been initialised to anything and contains garbage therefore garbage in = garbage out

Member Avatar for WaltP
0
172
Member Avatar for rectifryer

[QUOTE=Fbody;1163510]3. Line 51 NEVER, EVER, EVER, NEVER recursively call main(). [/QUOTE] Just to expand this statement a little and say that calling main in C++ is expressly forbidden by the standard and some compilers will produce an error. That is one of the many differences between C and C++, calling …

Member Avatar for Banfa
0
403
Member Avatar for janice777

Line 11 loanDurationon is defined without giving it an initial value Line 29 the code what would have given loanDurationon its initial value is commented out Line 32 loanDurationon is used in a calculation having nenver been given a value because line 29 is commented out. You need to assign …

Member Avatar for janice777
0
188
Member Avatar for SilentDuck

Almost everywhere you have a loop and access your arrays you have an out of bounds array access, for line declared as bool line[78]; then if it is accessed as line[N] N must conform to the constraint 0 <= N < 78 However [code=c++] void firstline(bool firstline[]) { int y; …

Member Avatar for Banfa
0
211
Member Avatar for Tech E

Create a structure (or a class) that contains your string and double and then make a vector of those. You can use a normal loop or one of the stl algorithms to perform operations on it.

Member Avatar for Lerner
0
108
Member Avatar for sikeufoo

How is y declared? You should perhaps check cin to make sure that no error has occured on it.

Member Avatar for Fbody
0
135
Member Avatar for JonEvans

max_element has 2 forums, one compares elements automatically using the < the other accepts a comparison function as well as the 2 iterators. Therefore either you need to put an operator< method into your structure or you need to provide a comparison function and use the second forum. In this …

Member Avatar for Banfa
0
141
Member Avatar for aianne

before trying to implement eliminating lifelines I think you code is in desperate need to refactoring to put common code in functions that can be called. For example: A function that asks the question Parameters: The question The 4 answers The right answer Returns a flag indicating if the question …

Member Avatar for WaltP
0
223
Member Avatar for vbcielle

Always keeping as much precision as possible is definately not a bad option, however there are others. For instance there is no point in keeping 15 decimal places of precision if the value represents a real world item with a fixed quantum of precision, for example cash. I can have …

Member Avatar for WaltP
0
210
Member Avatar for hkBattousai

Not for template functions (and classes). A template function are the instructions to the compiler on how to write the function given the parameter types... the template of the function. When the compiler compiles your code and sees a call to a template function it looks up the template function …

Member Avatar for hkBattousai
0
2K
Member Avatar for kd1987

Why can't you make a new object in the function and return it? Because you are returning const Text&? That is the mistake, you can't implement operator+ returning a reference, it has to return an object so the prototype for your operator+ should be const Text operator+(const Text &) const …

Member Avatar for Fbody
0
96
Member Avatar for Cerealkiller050

I am not seeing anything obviously wrong. When you are cerating the class objects I assume max is not 0, that would cause this behaviour. I would suggest modifying Course::generateClassList, at least temporarily to output max so you can be sure it is good. You have something strange going on …

Member Avatar for Banfa
2
98

The End.