560 Posted Topics

Member Avatar for crapgarden

Question #1. It's a C++ template, which is a powerful feature. Question #2. You have two variables with the same name in the same scope. That's a no-no in every programming language I know of.

Member Avatar for pseudorandom21
0
466
Member Avatar for LKMaxwell

[quote] myMatrix[j] = new myClass[yDimension]; // "error C2512: 'myClass' : no appropriate default constructor available" // Set the pointer to NULL - is this necessary? myMatrix[j] = NULL; [/quote] You should set it to NULL before allocating memory, and after deleting the memory. No that's not necessary there. you could …

Member Avatar for pseudorandom21
0
240
Member Avatar for mitrious

Anybody feel like checking out the TR1 random number generation facilities? I think it will let you specify a larger range.

Member Avatar for pseudorandom21
0
1K
Member Avatar for Lord_Migit

I'm assuming the pointers point to dynamically allocated data, probably allocated with "new" ? In that case, it is very important you do not lose track of the pointers that point to data allocated with "new". When you copy a pointer to the vector that has pointers in it, if …

Member Avatar for Lord_Migit
0
145
Member Avatar for elsiekins

There is most likely a warning level you can set to have the compiler only display more critical warnings. [url]http://www.cplusplus.com/reference/string/getline/[/url]

Member Avatar for Narue
0
259
Member Avatar for jasleen12345

in this header file are useful character manipulation functions: [url]http://www.cplusplus.com/reference/clibrary/cctype/[/url] and on a random side note, I would set the loop up like this: [code] while( fin.get(c) ) { if( c == '\n' || c == '\r' )//<-- not guaranteed to work. lines++; //... } [/code] \r is the carriage …

Member Avatar for ravenous
0
637
Member Avatar for teppel

Using Visual Studio the exception class has a constructor overload with a C string as it's parameter. G++/GCC do NOT have that overload. So blame Microsoft's compiler, then convert your exceptions to std::string. [b] also this is absolutely WRONG! [quote]void main()[/quote] [/b] [b] Use instead [code]int main()[/code] [/b] [i] Please …

Member Avatar for pseudorandom21
0
512
Member Avatar for Akill10

[code] void Add(DataType p_item) { int m_newSize = m_size+1; DataType* tempArr = new DataType[m_newSize]; for(int i=0;i<m_size;i++) tempArr[i] = m_array[i]; tempArr[m_size] = p_item; m_size = m_newSize; if(m_array!=0) delete[] m_array; m_array = tempArr; tempArr = 0; }[/code] Well there are some serious problems with this. I expected your class to be something …

Member Avatar for Akill10
0
223
Member Avatar for xXProgrammerXx

[url]http://msdn.microsoft.com/en-us/library/dd144879%28v=VS.85%29.aspx[/url] Google'd it.

Member Avatar for pseudorandom21
0
89
Member Avatar for patrickmh

[quote] usingstd: :cout: usingstd: :cin: usingstd: :end1: usingstd: :setw: [/quote] Surely you meant: [code] using std::cout: using std::cin: using std::endl: using std::setw: [/code] But since your program is so small it would be wise to: [icode] using namespace std; [/icode] ! This shall not pass: [quote] cout << end1 << …

Member Avatar for pseudorandom21
0
157
Member Avatar for blee93

Probably some input left in the stream. There are tutorials for avoiding this. Which is probably the best idea if you want to know what's going on. Otherwise you can use my method: [code] int someInt = 0; cin >> someInt; //<- if the user bunks this up and //enters …

Member Avatar for blee93
0
123
Member Avatar for DGeneral

Microsoft Visual Studio 2010 file. If you can re-build the project and link your runtime to the .exe statically that should fix it. (change an option in the project settings) Otherwise, you can try putting the debug dll in the same folder as the .exe, or one directory above it …

Member Avatar for pseudorandom21
0
268
Member Avatar for winecoding

may want to initilize the static variable to 0 to start with. It will have a positive value while instances of the class exist, otherwise 0.

Member Avatar for pseudorandom21
0
101
Member Avatar for arthurav

I am familiar with neither, though I have used many a C++ library, and using only one or at the most two different libs will help maintain flexibility and minimize problems with the project. I would try to use only one, if possible.

Member Avatar for arthurav
0
129
Member Avatar for altXerror

woah woah woah, what's going on here? If you want a function to modify a variable as an argument to the function you can either pass by pointer or by reference. In this case you could also return the value. pass by reference: [code] void GetChar(char &ch) { cin >> …

Member Avatar for pseudorandom21
0
189
Member Avatar for pseudorandom21

It may have only been Visual C++ 6.0 or something, but I think I remember needing to add curly braces after a switch's case label to declare variables, is this still true with VS2010 and C++? ex: [code] switch( 1 ) { case 1: { int a; //<-- ok } …

Member Avatar for Saith
0
78
Member Avatar for realproskater
Member Avatar for pseudorandom21

I'm a college student, about to have an associates degree and start working on my Bachelor's for CS. I have a project that I've been working on for a while now, and I'm thinking about making it open source, and hosting it on sourceforge. The reason I would do so, …

Member Avatar for mike_2000_17
0
106
Member Avatar for pinky khan
Re: c++

He's using a 20 year old compiler that has a header file called "graphics.h", the compiler he's using probably produces 16 bit executables and supports non-standard C++. Ahh the amazing Turbo C++, it's still used in universities, typically in India. Though, this poster's profile says Pakistan. I would recommend OP …

Member Avatar for JSPMA1988
0
108
Member Avatar for Kanoisa

You could try implementing the sieve of eratosthenes using a vector<bool> or a bitset, the wikipedia page on the sieve is decent; the vector<bool> is for marking it as not prime. The indices would be the numbers. [url]http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes[/url] You also have other options, of course. It is my belief that …

Member Avatar for Kanoisa
0
288
Member Avatar for beejay321

Do you mean sort the characters of each string, or sort the array of strings? std::sort() [url]http://www.cplusplus.com/reference/algorithm/sort/[/url]

Member Avatar for pseudorandom21
0
178
Member Avatar for amanoob
Member Avatar for pseudorandom21
-7
237
Member Avatar for chaosgeneration

If your compiler has C++0x TR1 support, you can use the auto keyword for the type, otherwise you can use the iterator type. I'm not exactly sure what you want, but here is an example of iterating over a set with iterators. If iterators are new to you, you may …

Member Avatar for pseudorandom21
0
170
Member Avatar for Hayzam_#include

My suggestion (while maybe not the best, but is simple), is: [code] #include <iostream> #include <string> using namespace std; int main() { const string ping_command = "PING "; string input; cout << "Enter IP: "; getline(cin, input);//<-- gets a line of input into "input" string command = ping_command + input; …

Member Avatar for pseudorandom21
0
151
Member Avatar for Jutch

Random suggestion: could typedef your array so as to help ensure consistency. [code] typedef char matrix_type[100][50]; int foo(matrix_type m); [/code]

Member Avatar for Jutch
0
204
Member Avatar for lochnessmonster

Yes that is indeed a pointer to a function, a named one. [code] typedef void (*funcPtrType)(int someParam); funcPtrType pSomeFunc = nullptr; pSomeFunc = &someFuncWithTheRightParamsAndReturnType; pSomeFunc(1000); [/code]

Member Avatar for mike_2000_17
0
561
Member Avatar for lexusdominus

It's not managed C++ anymore, it's C++/CLI--there is a difference. managed C++ had the horrible syntax, C++/CLI is actually kind of decent.

Member Avatar for lexusdominus
0
211
Member Avatar for MultipleMoney

Sometimes data is left in the buffer of cin. check cin for !good(), cin.good() is not the exact opposite of cin.bad(). good() will return true if no error bits are set, false otherwise. Afterward you will want to clear() the errors bit, and sync() the buffer associated with the stream …

Member Avatar for MultipleMoney
0
1K
Member Avatar for juangalvez4

I would also like to add that the input stream is not checked for errors in the example you have been given, so if you type a letter when it expects a number it will probably cough & die or cough & infinite loop.

Member Avatar for pseudorandom21
0
137
Member Avatar for Prasanna Venkat

I think the stl container template, std::vector<T> will help you with the dynamic allocation, and the STL algorithm std::random_shuffle() will help you obtain new matrices--as for the random number generation, if you have C++0x TR1 support on your compiler, you can use the new random number generation facilities which includes …

Member Avatar for pseudorandom21
0
186
Member Avatar for fabricetoussain

to make more readable: Functional decomposition, which involves breaking the program into segments and using functions for them. For instance, getting your input could be in it's own function. Personally I would probably use an array of floats and enum values for indexing it. ex: [code] enum //<-- anonymous enum …

Member Avatar for pseudorandom21
0
113
Member Avatar for Zvjezdan23

Also, the functions in <cctype> may be helpful. particularly isspace() and isalnum(). #include <cctype>

Member Avatar for KKR_WE_RULE
0
364
Member Avatar for becool007

The reference for the DrawText function says it's a pointer to a RECT structure, [url]http://msdn.microsoft.com/en-us/library/dd162498%28v=vs.85%29.aspx[/url] The reference for the RECT structure says it's four LONG variables, [url]http://msdn.microsoft.com/en-us/library/dd162897%28v=vs.85%29.aspx[/url] So you can make a RECT like this: [code] RECT drawingArea; memset(&drawingArea, 0, sizeof(RECT)); drawingArea.top = 0; drawingArea.left = 0; drawingArea.right = 150; …

Member Avatar for caut_baia
0
155
Member Avatar for akase2010
Member Avatar for emreozpalamutcu

If you're using Windows... Research some Windows API functions. If memory serves me, you'll want to enumerate the processes then it may be required that you get the path to the executable. [url]http://msdn.microsoft.com/en-us/library/ms682623%28v=vs.85%29.aspx[/url]

Member Avatar for cool_zephyr
0
8K
Member Avatar for becool007

The problem is here: [code] class PaintHandler{ }; [/code] That shouldn't be in your source file.

Member Avatar for becool007
0
182
Member Avatar for pseudorandom21

Okay, so the problem is: I need a way to display a graphic with a few lines of text over the picture. An amount determined at run-time of these will be created. They also needs to be contained in a scrollable container, and scroll properly. It sounds simple but I'm …

Member Avatar for pseudorandom21
0
146
Member Avatar for gaurav_13191

Yeah you could make a notes application, or a scheduler which would alert the user at a certain time, etc. and when you say "third year" does that mean you're on year 3/4 for a bachelor's degree? I would make something useful to yourself, I have a few of them.

Member Avatar for pseudorandom21
0
150
Member Avatar for saumya_kapila

[quote]I have to write a code[/quote] Okay, well then these pages will be helpful for you: [url]http://www.cplusplus.com/reference/iostream/fstream/[/url] [url]http://www.google.com/search?q=Clear+console+screen+in+C%2B%2B&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a[/url] Oh shi** my power is going out.

Member Avatar for HeartBalloon
-1
185
Member Avatar for pseudorandom21

If a U.S. government agency were to infect a PC with a virus, would it be possible to detect it with personal anti-virus software? If so, what's the best bet software wise?

Member Avatar for jholland1964
0
72
Member Avatar for juanp
Member Avatar for pseudorandom21

How are iterators used in C# ? suppose I have say: [code] List<int> someList = new List<int>(); /* assume some items are added here */ /* and now I wonder if C++ style iterators are available? */ for( var i = /* iterator begin of list */ ; i != …

Member Avatar for kvprajapati
0
117
Member Avatar for becool007

The most likely reason they don't like .NET is because of vendor dependence, namely .NET code only working on Windows. The majority of the world uses Windows, and if you fear that may change, or you like Linux oh so much then you should steer clear of it.

Member Avatar for becool007
0
269
Member Avatar for gregarion

I think you will have to use a stream manipulator for that, I forget which one, maybe std::ios::fixed or std::ios::setprecision. They're in <iomanip>. [url]http://www.cplusplus.com/reference/iostream/manipulators/[/url] You can set the output stream to display leading zeroes, but my question is why do you want the zero to be shown?

Member Avatar for deltamaster
0
527
Member Avatar for Mayank23

Oh yeah, I had a problem with that when I was first learning C++ too. = assigns to whatever is on the left side of it.

Member Avatar for Mayank23
0
158
Member Avatar for pseudorandom21

C++/CLI @ runtime add a PictureBox to a tab control, I need to do this at run-time because they're to represent some data the user must be able to manipulate. I actually need them to be in some kind of scrollable panel on the tabcontrol. Any ideas?

Member Avatar for jonsca
0
149
Member Avatar for lochnessmonster

Hmm, well.. here you can assign a name to a function pointer... [code] typedef void (*someFunc)(int param); someFunc func_pointer = nullptr; [/code]

Member Avatar for mike_2000_17
0
77
Member Avatar for kchyn

This may be helpful for you (Windows only): [url]http://msdn.microsoft.com/en-us/library/ms810467.aspx[/url] This may also be helpful: [url]http://www.libusb.org/[/url]

Member Avatar for pseudorandom21
0
3K
Member Avatar for pseudorandom21

Hello, I thought I was doing things right when I created a delegate to call a function to access the container's data, but it still throws an exception. I have something similar to: [code] public ref class myform : public System::Windows::Forms::Form { private: System::Windows::Forms::ComboBox^ form_combobox; private: delegate String^ getItemDel();//<-- delegate …

Member Avatar for pseudorandom21
0
162
Member Avatar for AmerJamil

1. int a[ ][ ] ={{2,3},{3,4},{4,5}}; i. It will create a 3*2 matrix and initialize it 1. 2. 1. [ [2][3] ] //<-- one way to think about it. 2. [ [3][4] ] //3 x 2 3. [ [4][5] ]

Member Avatar for VernonDozier
0
128

The End.