- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 3
- Posts with Upvotes
- 3
- Upvoting Members
- 3
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
24 Posted Topics
Re: [code=c++] for (int i=0; i<rowsa; i++) { for (int j=0; j<columnsb; j++) { float sum = 0.0; for (int k=0; k<columnsa; k++) { //first, look it as a two-dimensions array, you will get the following expression //sum += matrixa[i][k] * maxtrixb[k][j]; //then convert it to one-dimension array, you will get … | |
Why constructor can not be defined as virtual? Thanks | |
Re: [QUOTE=cpp_noobsauce;586700]Thanks for that. As I said I know that there are several errors in this code, thanks for helping fix that one. Any help with how to replace an instance of a character in the array with the first character of the array would be greatly appreciated :)[/QUOTE] [code=C++] int … | |
Does it need a copy constructor and an operator= for a class which have array member? for example: Class A { private: B data_[100]; //B is a class }; does class A need a copy constructor and an operator? in other words, is the default copy constructor is OK for … | |
Some of my source files include the following code. [code] #ifndef AAAAAAAAAAAA #define AAAAAAAAAAAA #if !defined(__lint) && !defined(_lint) XXXXXXXXXXXXXXXXXXXXXXXXX; #endif #endif [/code] I want to delete line1, 2, 6. So, Could somebody tell me how to do it? thank you in advance! | |
Re: Maybe, you confused the functionality of Event struct and Node struct. There are two ways to reach you objective. First, [code] struct EventNode { tm startTime, endTime; string eventItem; string eventNotes; char allDay; EventNode* next; }; struct EventList { void addEvent(); ... // other member functions used to sustain the … | |
Re: Please see my comments below [QUOTE=shipeshipaca;680395] [ICODE]Book::Book(string Title,string AuthorLastName,string AuthorFirstName,string PublishingCompany,int SeriesNumber,int NumPages,int CopyrightYear,string Series): m_Title(Title), m_Series(Series), m_AuthorFirstName(AuthorFirstName), m_AuthorLastName(AuthorLastName), m_PublishingCompany(PublishingCompany), m_SeriesNumber(SeriesNumber), m_NumPages(NumPages), m_CopyrightYear(CopyrightYear) { fstream filehandle; string filename=m_Title+".txt"; char m_filename[80]; for(int i=0;i<filename.size();++i) { m_filename[i]=filename[i]; } [COLOR="Red"]//the c-style string should end with a '\0', //so add line m_filename[i] = '\0'; //define … | |
Re: I think you maybe misunderstand the meaning of index and size. There are some errors in your code, please see my comments below. I attached my code, which is base on yours. Please refer to it. [QUOTE=henpecked1;679639]How do you delete the front cell of an array in an array based … | |
Re: Which container do you use to store the number? vector? list? if you use list, you can use the unique(op) function to eliminate the duplicate number. the op is a function or a functional object used to predicate whether two number is equivalent. | |
Question is : Write a function [code=c++] int f(char* str, long pattern) [/code] to find out how many pattern does the str contain? str is a char array consist of '1' and '0'; for example: str = "11010101110101011110100011001" ,pattern = 110; My solution is change pattern and str to std::string, … | |
Re: You can not pass a array to a function without the element number of each dimension. in the function, it will not know the number of the elements. 1. you can use struct to pass multidimensional array. for example: struct aaa { int value[10][20]; } int function (struct aaa& parameter) … | |
Re: It wrong here: [code=c++] for (counter = 0; counter < 6; counter++) if(sellItem == itemName[counter]) [/code] if there are less than 6 item in itemName, it will occur memory error. | |
Re: I am not sure I understand what you want. Maybe, the following code can help you. I write it using C++, you can translate it to C. This code can replace the text [icode]Set wallpaper="aaaa" [/icode] with [icode] Set wallpaper="text"[/icode] [code=C++] int main(int argc, char *argv[]) { string text = … | |
What will happen if caught exception when new a object? For example: [code=c++] ClassTest* ptr = 0; try { ptr = new ClassTest; } catch(...) { } [/code] if the constructor of ClassTest throw exception, what will happen? will ptr == 0 ? some memory leak? | |
Re: [quote] for(x=0;x<5;x++); [/quote] delete the ';' at the end of this line | |
Re: I have finished it, but to don't violate the rules of this website --"Don't give away code" , I can not give you all my source code. The following is the framework of program. hope it can help you. [code=c++] #include <iostream> #include <vector> using namespace std; struct Student { … | |
Re: [QUOTE] Are references less or more efficient than using pointers? [/quote] I think it's more efficient than using pointer. [quote] Also, if I were to call this function, would the second parameter be simple of type double? or would it be double*? [/QUOTE] just be double. | |
Re: I found two problem. 1. if you use the following code to open a file, the file must exist before running your program. [code] f1.open ("doc1.txt", ios::in | ios:: out); [/code] you can just use the default flag to open the file. 2. [code] str[i]=(str[i]=='C'|| str[i]=='c')? 'blue': 'c'; [/code] the … | |
Re: Why you want to change vector<int> to float? Do you want to use the float total to store the sum of the exam codes? maybe you can add a member to your struct. like this: [code] struct exam { int examid; vector <int> examcodelist; float total; }; [/code] In addition, … | |
Re: The various combinations of the flags and the corresponding meaning as below: [code] ios_base Flags Meaning in Reads (file must exist) out Empties and writes (creates if necessary) out | trunc Empties and writes (creates if necessary) out | app Appends (creates if necessary) in I out Reads and writes; … | |
For a singleton class, there is only one instance in a process, so it's not necessary to define a member function as static, am I right? Thanks in advance. | |
Re: Do your address have space? cin can not read a string with space. maybe you should use getline to read the address. | |
There are two way to define a character array constant: 1. const char* const OUT_STRING="hello world"; 2.const string OUT_STRING="hello world"; which one is better? why? |
The End.