1,358 Posted Topics

Member Avatar for Cross213

[QUOTE=Cross213;1626652]The error I'm getting when debugging (dynamic arrays): Unhandled exception at 0x5bfa782d in Ass4DynamicArrays.exe: 0xC0000005: Access violation writing location 0xabababab.[/QUOTE] You'll have to post some code for anyone to know for sure what's going on, but you appear to be de-referencing an un-initialized pointer. Have you verified that you are …

Member Avatar for Cross213
0
234
Member Avatar for Muralidharan.E

[QUOTE=mike_2000_17;1617776]I can only give you an example in C++, because, to my knowledge, you cannot do compile-time polymorphism in Java. (and anyways, such a question belongs in the Java forum) This is dynamic polymorphism in C++: [CODE] #include <iostream> struct Animal { virtual void doCry() = 0; }; struct Dog …

Member Avatar for Fbody
0
596
Member Avatar for AshfaqueIW

It depends on how you intend to use the vector. In general, however, NO you don't want to specify a vector's size when you declare it. There are very few situations that REQUIRE the vector to be initialized immediately.

Member Avatar for Zvjezdan23
0
181
Member Avatar for opawix

What do you know about the differences/similarities between the while and do-while loops?

Member Avatar for opawix
0
146
Member Avatar for Zvjezdan23

What Narue is saying is that you need to elaborate on what your problem is. There are extremely few people here that can magically divine such information. You can get help here, but you need to tell us what your understanding of the issue is before we can even begin …

Member Avatar for Zvjezdan23
0
160
Member Avatar for moneypro

Honestly, this code looks like it may be an overly-explanatory example from a text. The code contains many things that you generally won't see in well-designed/written code. I suggest you read the chapter it's part of a little closer. Here is a highly generalized summary (I want to avoid doing …

Member Avatar for moneypro
0
179
Member Avatar for bxdfjmkl

Click your Start menu/Windows button. Locate the (My) Computer icon/button. Right-Click the icon and select Properties. There is a field in the dialog that appears that tells you.

Member Avatar for pseudorandom21
0
111
Member Avatar for treger69

[edit]I know this is a little late but...[/edit] [B]>>I am using Visual Basic C++ 2010 if that helps[/B] Here is your problem. There is no such thing as "Visual Basic C++". It's either Visual Basic or Visual C++. Is your class using the Basic or C++ language that is included …

Member Avatar for prvnkmr194
0
423
Member Avatar for George91340

You have to use setw() [B]immediately before[/B] the output you want in the "column".[CODE] //example: //outputStream << setw(width1) << data1 << setw(width2) << data2 ... std::cout << setw(10) << data10 << setw(20) << data20 << //...[/CODE] You are using it after all of your output has already occurred. In that …

Member Avatar for pseudorandom21
0
239
Member Avatar for Geek-Master

[QUOTE=saulocpp;1176085]I'd like to bump this old thread since 2d arrays are a huge problem for the majority of C/C++ programmers. If one needs the array to be dynamic, the nightmare is there. This page has good explanations: [url]http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html[/url] But it never mentions the real problem, that is, the vector resize …

Member Avatar for Hialek
0
5K
Member Avatar for Sonia11

It's the definition of a template class:[CODE] template <typename T> class Reverser { std::vector<T> stuff; //other member declarations & definitions };[/CODE] This defines a class, called "Reverser", that contains a vector (called "stuff") whose complete type is template/instance dependent. For example, a declaration such as [icode]Reverser<int> revInt;[/icode] would cause Reverser::stuff …

Member Avatar for mrnutty
0
310
Member Avatar for Trustify

First, please use [noparse][code]...CODE tags...[/code][/noparse], they make your code easier to read. See:[CODE]#include <iostream> #include <fstream> using namespace std; int main() { const int SIZE = 81; char input[SIZE]; fstream dataFile; dataFile.open("info.txt", ios::in); dataFile.getline(input,SIZE); system("pause"); return 0; }[/CODE] Second, whenever you are dealing with file streams, you should make sure …

Member Avatar for Trustify
0
163
Member Avatar for gregarion

I'm not famiiar with boost, I don't use it. Based on what I'm seeing though, you may want to search the documentation for the "boost::tokenizer" type. You probably need to provide an argument to a function somewhere that tells it to use whitespace characters as the tokenization character(s). It could …

Member Avatar for vijayan121
0
413
Member Avatar for GhostMonkey

The "sql" file is probably part of the "behind-the-scenes" stuff that VS does when you build the program. It's probably not actually an sql file, but something that has a filename extension similar to a file type used by SQL CE. Have you actually built the project? You have to …

Member Avatar for GhostMonkey
0
116
Member Avatar for narunaru

My guess would be 10.0e+6 (10-million). But you're right, that is a strange way to indicate the desired limit... It could also be 10.0e+3 (10,000), but that would generally be 10k.

Member Avatar for Dexxta27
0
118
Member Avatar for cestra

Try to compile and run this:[CODE]#include <fstream> #include <iostream> #include <string> using std::cout; using std::endl; using std::ifstream; using std::ofstream; char const * const fileName = "testFile.txt"; int main() { cout << "This is a file read/write test app...\n" << endl; { //open section 1 ofstream outFile(fileName, std::ios::out | std::ios::trunc); outFile …

Member Avatar for cestra
0
206
Member Avatar for zulkefli82

[B]>>Also, in order to calculate the total sales for a single division, can't you do that in the constructor for the DivisionSale class?[/B] I'm not too sure I agree with this suggestion. From a purely logical standpoint, that makes sense. From a class design standpoint it really doesn't though. That …

Member Avatar for zulkefli82
0
119
Member Avatar for munitjsr2

Arrays and vectors are not the same and are not interchangable. You can not make (in your case) a DAI* point to a vector<DAI>. They are incompatible types. You will need to do this as either strictly vector or strictly array. If you choose array, I suggest that you [URL="http://www.cplusplus.com/doc/tutorial/dynamic/"]read …

Member Avatar for Fbody
0
314
Member Avatar for hawita

The C++ language has "compound" operators. The '+=' operator is used to increase the current value of the Left-Hand operand by the value of the Right-Hand operand. Thus, the statements:[CODE] int a = 10; a += 10;[/CODE] Would cause an integer variable, called 'a', to be declared and initialized to …

Member Avatar for Fbody
0
316
Member Avatar for Khoanyneosr

The thing you need to remember is that, unlike some loops in some other languages, in C++ [B]all loops execute on a true condition[/B]. You either need to change the initialized value of "done" to false or remove the "not" ('!') from your condition.

Member Avatar for Fbody
0
104
Member Avatar for tikoti

You really haven't explained why you want to do that. Is it some sort of misguided attempt at condensation/optimization? You do realize that this will probably create a larger executable because of the stuff that happens "under the hood" inside the class, don't you?

Member Avatar for tikoti
0
172
Member Avatar for IndianaRonaldo

So what do you do then if you want to use a string literal, and guarantee that you'll be able to edit it later? Create a constant for it, then use strcpy() (or similar)? I suppose it makes sense, its sort-of considered "best practice" when working with numeric literals (as …

Member Avatar for IndianaRonaldo
0
348
Member Avatar for murnesty

You are attempting to re-declare the class in the implementation file (the *.cpp file) instead of simply implementing the member methods. What you need to do is declare it in the header (the *.h file), then implement it in the *.cpp file using the scope-resolution [noparse]operator ( :: ):[/noparse] [CODE]//myClass.h …

Member Avatar for murnesty
0
146
Member Avatar for ahp@aol.in

It's a static member. Only one instance of the member variable exists in the whole program and all instances of the class access the same variable. Additionally, an instance of the class is not required to access it. It can be accessed "directly" from any scope the "test" identifier is …

Member Avatar for ahp@aol.in
0
417
Member Avatar for SWEngineer

I don't work w/ Qt, so I can't say definitively. Is this a function call that must occur within your main() or is it a function definition? Since you say it's a "line", I'm guessing it's a function call from main() to the actual beginning of your applicaion. Assuming that's …

Member Avatar for Caligulaminus
0
218
Member Avatar for sing1006

You're also missing a ';' after your prototype on Line 2. Also, while you're at it, you should change your main() to return-type [B]int[/B] and add a [iCODE]return 0;[/iCODE] at the end of the function. This is where the whitespace lecture occurs. Make better use of whitespace and your code …

Member Avatar for Fbody
0
186
Member Avatar for king03

What's confusing you? Do you understand how loops work in general? I have a suspicion about what's confusing you and I suspect that part of your answer will come from answering this question: "Where does the variable/value 'i' come from?". Proper formatting will also help (with some "modernization"):[CODE] #include<iostream> int …

Member Avatar for Fbody
0
2K
Member Avatar for Skabix

[QUOTE][CODE] 13. day = seconds / 86400; 14. seconds = seconds % 86400; 15. hour = seconds / 3600; 16. hour = hour % 3600; 17. minute = seconds / 60; 18. minute = minute % 60; 19. seconds = seconds % 60;[/CODE][/QUOTE] You're overwriting your hour and minute answers …

Member Avatar for Skabix
0
1K
Member Avatar for Howdydoody

It's probably an operator precedence issue. The 'dot' operator activates before the "index" operator so you don't have the object yet. Try adding another set of parentheses:[CODE](directedGraph[numSource]).edgeList.push_back(edgeString);[/CODE]

Member Avatar for Howdydoody
0
484
Member Avatar for Lokril

You don't want a for loop in this program. You want a while loop. Narue's structure is essentially what you need (although you really should re-write it in a manner that's appropriate for your skill-level). The part of the code that determines whether it's odd or not, and reacts accordingly, …

Member Avatar for Lokril
0
216
Member Avatar for clickspiker23

No, Your original code is essentially correct. The problem I see is that the "middle" object is not initialized anywhere, it's a default object. As a result, you are most likely getting garbage values when you call middle.getX() and middle.getY(). What does your "Point" class' default constructor look like? What …

Member Avatar for JasonHippy
0
140
Member Avatar for kumarmpk4u

Have you written the implementations for the functions? Simply declaring, but forgetting to write, the functions is the most common cause for that type of Linker error. Also, if you have, make sure the *.cpp file that you implemented them in is included in your project. The error basically says …

Member Avatar for kumarmpk4u
1
324
Member Avatar for jnewing

I don't see '7d' in your data anywhere, did you mean '7c'? What if you read it char-by-char until you hit the '|' char? Reading into a struct is basically the same as reading into a variable, you just have some extra syntax related to the member access:[CODE] struct myData …

Member Avatar for jshoot
0
114
Member Avatar for sha11e

[B]>>But how should the linking look (where should I have my #includes? should i include both declerations and header to the main.cpp? or...? :///)[/B] It is extremely rare that you would have to #include a *.cpp file in another file. You would #include your header file in both *.cpp files:[CODE]//myClass.h …

Member Avatar for mike_2000_17
0
278
Member Avatar for Derek Elensar

Using quotes ("[I]blah[/I]") instead of angle-brackets (<[I]blah[/I]>) changes the compiler's behavior while it searches for the #included file. Using quotes makes the compiler look in the source file's local directory, then the default include directory. Using angle-brackets makes the compiler go directly to the default include directory and ignore the …

Member Avatar for Derek Elensar
1
13K
Member Avatar for ayan2587

I'm afraid I'm not familiar with the term "bit array". One use of individual bits is as a way to make your resource usage more efficient. A bit only has 2 states ON(1) and OFF(0). These states can be used to represent individual yes/no, true/false, etc. values in a more …

Member Avatar for mrnutty
0
124
Member Avatar for wildplace

[QUOTE][CODE]void changePTR(int* p){ int z = 100; int* o = &z; p = o; // p = null // this doesnt work also..?? }[/CODE][/QUOTE] I know you said assume that 'o' is dynamically-allocated, but it's not, and given this example code that's not a reasonable assumption. There are significant logical …

Member Avatar for wildplace
0
96
Member Avatar for hous3aholik
Member Avatar for KazenoZ

Try compiling a "Release" version instead of a "Debug" version. Then make sure you send the files from the "Release" folder instead of the "Debug" folder. They link to different libraries. Because of the library differences, a "Debug" version will only run on a system that has VS installed on …

Member Avatar for KazenoZ
0
254
Member Avatar for hawita

What have you managed to write so far? You'll need [URL="http://www.cplusplus.com/reference/clibrary/cmath/"]the <cmath> header[/URL] to access sin and cos.

Member Avatar for Fbody
0
54
Member Avatar for ayat taj

We're here to help, but you need to help yourself first. We guide to solutions, not hand them out on silver platters. Other than an easy 'A', of what benefit is it to you if we just give it to you? Answer: None. In fact, it's a hindrance to you. …

Member Avatar for Fbody
0
213
Member Avatar for kumaresen

The identifiers "clrscr" and "getch" are found in a header that you haven't included. I'm not going to give you the name of the header because you shouldn't be using it anyway. You'll have to find different ways to clear the screen and get character input. @JasonHippy: get[B]ch[/B] is not …

Member Avatar for Fbody
0
287
Member Avatar for kumaresen

[QUOTE=L7Sqr;1536053]Please use code tags when posting code. To answer your question: Change [icode]char letter;[/icode] to [icode]char letter = 'F';[/icode] That will initialize the letter variable to some known value and ensure that non-random data is not used if nothing else is assigned. In your case, if total is less than …

Member Avatar for JasonHippy
0
228
Member Avatar for Dexxta27

@OP: "It gives a whole bunch of errors." is not a very clear description of your problem. You really should be more specific about the errors. Given what I'm seeing so far, I suspect that there are way too many to post, so I suggest you post just the first …

Member Avatar for ravenous
0
176
Member Avatar for daviddoria

[QUOTE=daviddoria;1535286]I was under the impression that you could completely gaurd anything you wanted with an [icode]#if 0 [/icode]. Apparently this is not the case? I found some code that has opening /* comments but no matching closing */, and the /* seems to comment out the [icode]#endif[/icode], resulting in everything …

Member Avatar for daviddoria
0
135
Member Avatar for gla41247

[QUOTE=kalsi_amandeep;1535267]How long will you take for this??[/QUOTE] I'm sure it was done the same day, or possibly the next. However, considering the fact that this thread is about 2-months old and the OP only has one (1) post, there are 3 possibilities: 1. The OP decided to solve the problem …

Member Avatar for Fbody
0
351
Member Avatar for Loki55

Your function is declared to return an int. As a result, the decimal portion of the return value is being truncated.

Member Avatar for EmilyJohnson
0
97
Member Avatar for Khoanyneosr

There's no need to be a prick about it. Transposition of characters is a subtle-enough error it can be hard to spot. Especially if the person has dyslexia (not that I'm implying they do). @OP: Your window handle is "hgMainWnd", you've transposed the 'h' and the 'g' in your variable …

Member Avatar for Khoanyneosr
0
170
Member Avatar for dophine

[QUOTE=pritamsingh98;1532516]An abstract class is one whose object cannot be created and inheritance is the property in which super class inherit the property of base class.[/QUOTE] You need to pay closer attention to your terminology. An abstract class is one that cannot be independently instantiated, you have the right basic idea …

Member Avatar for Fbody
0
184
Member Avatar for geir88

It looks like a demonstration of arrays as pointers in conjunction with a demonstration of pointer arithmetic. The version that works is a convoluted way of assigning the reference (address) of chr to ptr.

Member Avatar for Fbody
0
112

The End.