1506 byte By
firegun9 at 2007-11-20 11:13:16
hi,I am in windows xp sp2 and the compiler is GNU Make 3.80 (gcc 3.4.2)I am trying to use a multiset iterator to update the content of each element in a multiset. The content is a vector of pointer. Here is the partial code:Entity.h---class Trade{ ...};class Meeting{ ... vector<Trade*> t...
1858 byte By
Omega234 at 2007-11-20 11:13:18
I've been working on a timer program that works similar to my last one, only this time it's counting up. It works fine, except for two things:1. Whenever se (seconds elapsed) goes over 59, it skips to 1 (instead of displaying 00)2. I want to include nanoseconds in there, but I'm not...
408 byte By
CppLover at 2007-11-20 11:13:40
Hello everyone, I am wondering and curious here about the following:Can one change the font size of the C++ Win32 Console Application program?If yes, how? I'm still new to the console application manipulations.Also, is there a good website with tutorials to follow and learn on my own about mani...
165 byte By
ccfriend at 2007-11-20 11:13:55
Hi<br/>I look for a C/C++ library that provides API to access file, network stream, database etc in an abstract way. Is anything good available?<br/>Thanks
2230 byte By
douche at 2007-11-20 11:14:10
Hi again, I am trying to compile the following:#include "stdafx.h"#include <iostream>using namespace std;void printTemperature(int[][7], float[], int);void printTemperature(int temp[][7], float average[], int row}{ cout << "\n\n\n\n\n The Temperature array is: Weekly Av...
1693 byte By
inbugable at 2007-11-20 11:14:13
Background.. Basically I need a large 2D array accesable throughtout the program, the size and contents of which isn't known until a file is loaded from disc.I figured I should use a class to avoid global variables and a vector for the data so it could be increased in size when required.I plan...
Hi. I'm getting a memory exception when I run the following code. I'm using DevCPP 4.9.9.2.----ex.cpp------#include <iostream>#include "Matrix.hpp"using namespace std;int main() { cout << "starting ex" << endl; Matrix<float> mymatrix(4,4); cout << "...
Hi,I overload the ++ operator, and i define the overloaded funtion as a member function in my class. I define the function to take one int argument. Here is the code for the program.class A{public : void operator++(int a); A(); A(int a); int get() const;private: i...
when i compile the following code about function overloading the compiler throws the error message:" ambiguity between 'abso(int)' and 'abso(float)' "#include<iostream.h>#include<conio.h>int abso(int i);long abso(long l);float abso(float f); main(){clrscr();abs...
199 byte By
coricori at 2007-11-20 11:14:32
Hi there<br/>How to implement a timer in C++ as is in VC the timer control.<br/>Where can I find a description about how timer control works in VC. It's such a class/method in Win API?
957 byte By
Sucrac at 2007-11-20 11:14:33
For those who don't care about the back story, skip this paragraph:I can't seem to catch the key press events, I have tried getchar() but that requires pressing enter, and also doesn't tell me when the button is being pressed... Anything I search comes up with "Borland compiler, windo...
I have a section of code that needs to work like this in C++.What it does is take the input from a variable to store it in an integer. What I need to do is check that the input was indeed a number, and not a character or string or double. How do I check that the user input was in the correct format...
849 byte By
George2 at 2007-11-20 11:14:38
Hello everyone,I am porting a legacy program from other platform to Linux. I am using Red Hat Linux Enterprise 4. In the legacy program, there is a macro definition,#define __FILE FILEin the legacy program, __FILE will be used in all the places to stands for FILE.Here is the program to reproduce thi...
2362 byte By
baqualish at 2007-11-20 11:14:42
Hi, I'm programming in C++, but without a GUI (the console) so I wasn't sure where to put this.Anyway, for my first C++ program, I made a little text editor for the sake of understanding the whole fopen stuff. With my background knowledge of PHP this is going rather well, but I have encoun...
898 byte By
Zachm at 2007-11-20 11:14:51
This might be a really stupid question but it had me boggled for a minute.Suppose you have those classes:class A{public: virtual void foo(); virtual void foo(int n); }; class B : public A{public:virtual void foo();}; class C : public B{public:virtual void foo();virtual void foo(int n); }; Now, class...
Hi. I'm under the impression that an overloaded << function should not be a member function, but instead made a friend function of the class it applies to. I have done this successfully in another class of mine, but that being a template class was all defined in the header.I'm now ha...
Hi. I'm having trouble with a pretty simple class I've written. I'm new to separate compilation and I'm trying to get my head around it. So I suspect this is a problem related to that.I'm getting the above error message with the following code://ex.cpp#include <iostream&g...
464 byte By
visame at 2007-11-20 11:15:04
What does "pb may point to just B" mean exactly?Why it is not safe to use static_cast?Help needed.THANKS!!!// static_cast_Operator.cpp// compile with: /LDclass B {};class D : public B {};void f(B* pb, D* pd) { D* pd2 = static_cast <D* >(pb); // not safe, pb may...
183 byte By
k0b381 at 2007-11-20 11:15:08
I need help writing a function that takes a character parameter, <br/>and returns a number corresponding to a code. Cannot <br/>use any selection structures (ifs or switch).
I am designing a project that involves handling JPEG, BMP's and TIF files, I need to be able to display the image on screen, move it about (with keypad at first), and zoom in and out of it. And whether or not this would be included in the movement thing, but automating the movement is also nece...
Nevermind I got it to work
I need to find the sum of all elements of a given binary tree using recursion. This is exactly what my project asks me to do:A binary tree is well formed if: (a) it is the empty treeor (b) it consists of an integer element, plus two children, called the left sub...
1357 byte By
Sivakk at 2007-11-20 11:15:26
OK. I am calling a function and passing data to it and I want to write to a file using ofstream. Now, it works except for the fact that the file keeps having records overwritten (probably because it's being opened and closed everytime the function is called).Here's what the function look...
372 byte By
Omega234 at 2007-11-20 11:15:30
I need help with this code:system("ATTRIB +H " freqUN.c_str());All that the compiler gives me for an error is "parse". All I'm doing it I'm trying to hide the file freqUN.c_str (although it has a different name, based on whatever the user enters). I'm pretty sure that I'm just...
I have written a function that displays floats in binary format, and from every test I've done it agrees with the IEEE floating point representation of the number.This is the problem so far:I have a function F that theoretically converges to a number. If I give that function a float, it outputs...
The following simple code will not compile in visual studio 8 (ok in previous versions)#include <fstream>using namespace std;void readfile();double getNum(ifstream in) {return 1.0;}void readfile(){ ifstream in("input.odat"); double s = getNum(in);}The error message isError 1 error C2248: &...
1267 byte By
Sivakk at 2007-11-20 11:15:58
I've been doing up the project which I had mentioned in another post here, but now I'm thinking maybe my approach to the whole thing was flawed. Here's what basically happens:All threads need to be done using the POSIX or pthread.h and compile in Unix. G++.The project needs to use 6...
711 byte By
BoSCHoW at 2007-11-20 11:16:11
Hi all,it is possible to declere a function within a structure, then in the main function with the use of the pointers call this function and assign the specific parameters . To make my idea clearer check out the sample code.struct { int AND_function; int math_funct; int comp_funct...
521 byte By
lab1 at 2007-11-20 11:16:18
Hello, test is a vector<test> passed into the method. float precision = 0.0000001f; // toss out zero values for(size_t i=0, k = 0; i<test.size(); i++) { if(test[i] > precision) { nonZeroValues[k] = test[i]; k++; } }This code cra...
904 byte By
w1985 at 2007-11-20 11:16:21
Hi everyone,I've been working on this thing for the last few days i'm suppose to get a number between 80 and 100 yet i get a number around 2. I'd appreciate if anyone could please tell me what is going on? void linear (){double xi, yi, ei, n=16.00, N= 1000.00, xi_sq=0.00, e_sq=0.00, r...
1535 byte By
standmatt at 2007-11-20 11:16:25
Hey everyone, I'm writing this as part of a project for my computer science 4 class. We coded in java for the first 3 CS courses, and now we've switched to C++. I'm getting this error when I go to compile my code.g++ -ggdb -c SymbolTable.cppg++ -ggdb -o tli tli.o Scanner.o SymbolTa...
491 byte By
lab1 at 2007-11-20 11:16:39
Hello all,I have the following line of code that crashes and I dont know why:nonZeroLocations is a vector<int> that has 2 elements: [29, 30]vector<float> testBin;testBin.resize(0);transform(nonZeroLocations.begin(), nonZeroLocations.end(), testBin.begin(), bind1st(minus<float>(),1/...
I had an interview recently, and this was a question I thought was interesting: Write a function to efficiently clear a block of memory to a specific value. (do not call any external functions like memset) Assume that the native (int) is 32-bits. Assume that the alignment of the p...
Sorry to bother you guys. I'm a newbie to C++, only been programming for a month, but I need help grabbing up to 8 decimal places from a file.I've gotten it to grab 4 decimal places.Do I have to use a certain constant?Any help would be appreciated. I'm sure it is easier than I think.....
1253 byte By
nade at 2007-11-20 11:16:49
I am not sure where to ask this question.I have written a few wrappers in c++ for applications also written in c++.I wanted to see if I could hook some functions in a visual basic executable.Here is how my hook works:You make a dll and include all the exports (msvbvm60.dll) has. Like in my def file...
hello everyone, i am new to c++ and programming overall...just decided to try some things out..i am currently trying to implement the knapsack problem...this code works correctly no problem... but can someone please help me to rewrite this code so that ifstream.open would be used to read .txt file.....
2009 byte By
rmoore07 at 2007-11-20 11:17:02
Im trying to write a program for a college class and need some help..i need to create a program for a bank account. You have to pick how many months, your interest rate, and your starting amount. then have to put in how much you withdrew and deposited each month and its supposed to calculate how muc...
I have posted this on C++ forum rather than VC++ since I felt this is more appropriate.I have called GetAsyncKeyState(..) function. How do I check, if the most significant bit of the return value has been set or not. This is what I thout of, short sReturn = GetAsyncKeyState(..);if(sReturn == 0x1000...
2261 byte By
kmhui at 2007-11-20 11:17:35
I have a following class. The class codes compiled without a problem until it was compiling another code file that calls for the instantiation of this class and it gives compilation error. I cannot figure out what's wrong. The part that don't make sense to me is: Instantiation code:NmArrF...
A while back some of you helped out with a formatting question I had ( http://www.dev-archive.com/forum/showthread.php?t=430279) with STL.I have another:It's been decided that the units measure is needed in the log. That's okay - I already send the formatted value off as a std::string becau...
847 byte By
kenrus at 2007-11-20 11:17:49
My immediate supervisor has a requirement to build a class that inherits from std::list. My first thought was that we should consider building a class that has a member of type std::list. However, that idea was discarded.The stated goals are to make the std::list class easier to use. Primarily th...
646 byte By
lab1 at 2007-11-20 11:17:55
Hello,With Locations1 being of type vector<int> and Bin1 being of type vector<float>I have the following line of code:transform(Locations1.begin(), Locations1.end(), back_inserter(Bin1), bind1st(minus<float>(),1/2/Locations1.size()));So the following input Locations1;[29,30] should...
Say I am taking a line into a character array, like "abcd". Now, if the user inputs "abcd " , how do i tell the compiler to ignore the space and only take the letters into consideration?Here is what I have so far:#include "stdafx.h"#include <iostream>#include <string>using namespace std;...
913 byte By
kenrus at 2007-11-20 11:18:12
I am probably going abou this completely wrong, but how do I get the contents of a list ?Example:#include <list>using std::list;typedef struct TagListInfo{ unsigned long count1; unsigned long count2; unsigned long count3;}TListInfo;int myfunc(){ list<TListInfo>...
1191 byte By
SamWo123 at 2007-11-20 11:18:16
Hi.Can anybody help explain to me why the first getline() in the code below does not read content from the file through the end of file?The second getline() does read the whole file and display it via cout. However, if I omit the line in.clear(), then it displays nothing.Why was in.clear() necessary...
Hopefully there are some people out there that are good at C. I have this one file that is compiled as "ansi C" within the context of a larger program that is mostly C++. I am not very good at understanding global variable declaration and usage. Take a look at this:// The max numbers of threads t...
I want to accomplish this with only algebra. firstBi = bin / 10000; secondBi = bin - (firstBi * 10000); ans = 0; cout << firstBi;My code appears to me to be fine to me but if I input the binary number as 10011101 (157) the number that is output is -82654. I do not understand this.I could under...
236 byte By
visame at 2007-11-20 11:18:33
How can j=9 after the following codes?<br/>I think it should be 12.<br/>#define pro(x) (x*x)<br/>void main(void)<br/>{<br/> int i=3,j,k;<br/> j=pro(i++);<br/> k=pro(++i);<br/> printf("j=%d,k=%d",j,k);<br/>}
Hi. I'm having a problem with using an overloaded () operator in a class derived from that containing it. I have a template matrix class defined that works with no problems, and uses an overloaded () operator to access elements of it. However, my Vec2D class that inherits from the matrix will n...
OK, I will admit that I am over my head on a project. I am trying to convert a VS 6 project to VS .Net 2003 and I am getting the following compiler error:===================================InspectorPC error C2668: 'ATL::CStringT<BaseType,StringTraits>::__ctor' : ambiguous call to ove...