#include <iostream> struct Object { int size; // Want to avoid this because size is (almost always) constant Object (int s): size(s) {} // for every Object subtype.
[Code] ....
I want this:
#include <iostream> struct Object { virtual int getSize() const = 0; }; struct Block: Object { int getSize() const {return 5;} // always 5, except once in a blue moon it may change
[Code] ....
The Decorator Pattern works (getSize() can then return 6) but it is a poor choice for my program because it will cause more problems (due to many containers holding its old address, among other things. Any way to achieve this without any change of address, and without creating new storage somewhere, either inside the class or outside the class (too much responsibility to follow that stored value for the rest of the program just for this rare change, and creating a data member uses up too much memory for the many, many Block instances)?
I am creating a Matrix class, and one of the constructors parses a string into a matrix. However, printing the result of the constructor (this->Print()) prints what I expect, and an <object_just_created>.Print() call returns bogus data. How is this even possible?
Snippets below:
Matrix::Matrix(const string &str) { // Parse a new matrix from the given string Matrix r = Matrix::Parse(str); nRows= r.nRows; nCols= r.nCols;
[Code] ....
in the driver program, here are the two successive calls
Matrix mm6("[1 2 3.8 4 5; 6 7 8 9 10; 20.4 68.2 1341.2 -15135 -80.9999]"); mm6.Print(); // mm6.Print() calls bogus data, -2.65698e+303 at each location. The matrix's // underlying array is valid, because printing the addresses yields a block // of memory 8 bits apart for each location
I have written a C++ program I have multiple of CSV file used as input, which I open one at a time and close it after extracting data to a output file which is the only file.
I run getline(inFile,line); outFile << line << endl;
I run this code, and only part of it is goes to the output file I got, also have spacing randomly to specific file and inconsistent
But when I slower the code, like system("Pause") in the loop, I can get extract what I want perfectly....
Is my program running to fast, why getline would be skipping part of what things I want?
I'm trying to union eleven tables to call out data. Parent table is 'Events', child tables are 'SR1Laptimes', 'SR2Laptimes' and so on (there are ten SR... tables). Primary key in all tables is EventName. Parent/Child relationship is Events.EventName/SR1Laptimes.EventName etc All tables that start with SR have the same Schema. I'm trying to call out MIN(Q1) across all table but first need to Union them I believe. Here is my code.
myCommand.CommandText = "SELECT MIN(Q1), MIN(Q2), MIN(Q3), MIN(Q4), MIN(LaptimesMinutes), MIN(LaptimesSeconds) FROM (SELECT * FROM Events UNION ALL SELECT * FROM SR1Laptimes UNION ALL SELECT * FROM SR2Laptimes) WHERE (Events.Track = @track) AND (Events.Number = @number) AND (Events.Rider = @rider)"; myCommand.Parameters.AddWithValue("@track", analysisTrackComboBox.Text); myCommand.Parameters.AddWithValue("@number", analysisNumberComboBox.Text); myCommand.Parameters.AddWithValue("@rider", analysisRiderComboBox.Text);
error C3867: 'WordParsor::Form1::PutUpfrmIO': function call missing argument list; use '&WordParsor::Form1::PutUpfrmIO' to create a pointer to memberc:userskingc++wordparsorwordparsorForm1.h... and the suggestion fix generate another error.
One person suggested the gcroot<> object wrapper... but I do not know how to modify/declair the function or its argument type.
I wrote a program which detects a pattern in an array then returns a valve (x) for each time it does. now i tried to call function patt in main so that i can print x but it doesn't let me do it.
#include <stdio.h> int patt(const int SIZE, char str[], int i, int c); int main(void) { const int SIZE=21; char str[SIZE]={'1', '0', '1', '1', '0', '0', '1', '0', '1', '0', '1', '0', '0', '0', '1', '0', '1', '1', '0', '1'}; int i, c=0;
I want to write a function and be able to call it during execution (say during a while(1) loop). Is this possible without having to parse an input string to extract the function and parameters I need or is that the only way?
i think my function call is not working and i dont know how to fix it. Basically i want it to output my getstudent function and once i get the information i want it to output with the displaystudent.
When I call the member function in the main function, two functions are working fine but the third one(print()) is not. The program stops after executing the read_ages function and nothing printed on the screen. This is really strange and I could not find any problem after spending hours and had to post it here.It is a very simple program but I cant find the bug. It is a multiple file program and I am using MinGW as a compiler.
//File 1
#include<vector> #include<string> class Name_pairs { private: std::vector<std::string>names; std::vector<double> ages;
[Code] ...
//I haven't made the sort function yet since I am stuck with the print(). Seems //like the compiler is skipping the print() function.
I'm not a programmer, at least, not a good one. I'm a researcher and I need to implement this function and test it and use it for my research. I tested some clustering methods in JAVA and Matlab and also I want to test it on C. I don't know too much about programming, especially about C, I know nothing. I tried to implement some basic methods but I failed.
It's all about K-Means Algorithm. I'm working on a disease and I'm trying to find ways to early diagnosis. Anyway, these are details. The thing is, I found a 'free to use' function but I don't know how can I use it. I tried to learn something from Net, I downloaded a compiler, I paste the code and I get many errors... And I heard that I have to do some "calling function" stuff but I don't know how to..
The code is in the link below: URL....It's not imperative that using this function, it can be another one but it had to written in C.
I know there has to be a system call for a pause function. I simply want the program to pause for a few seconds before executing the next line of code. I do NOT want the user to enter a keypress, just pause the output or code execution for a few seconds.
system (pause); waits for keypress right? I just want it to wait 3 seconds before proceeding. I know it should take an argument for milliseconds right? Also, this is for a homework assignment I have already completed, just doll'in it up a bit for extra credit...maybe...
I need to call one function on my C++ program. I made one root calculator for functions, but, this doesn't work.
// FUNCION QUE CALCULA LA DIFERENCIA ENTRE 2 VECTORES real mn_error_vectores(Array1D< real > &u, Array1D< real > &v) { int i; if(u.dim()!=v.dim()){ printf("mn_error_vectores() : arrays of different dimensions