Search Results

Search found 2727 results on 110 pages for 'operator overloading'.

Page 36/110 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • mysqldump --where with = operator doesn't get all rows = - Help!

    - by JonathanLIVE
    I have a situation with a particular table that now thinks it contains 4 Petabytes of data. I know that sounds cool, but I assure you, it is only on a 60GB partition. This table has 9 fields in it. One of them is a domain_id field. It is the best field to identify the rows by, as there are only approximately 6300 of them. The only other field option to match has over 2million records, and thats just more difficult. I cannot do a straight mysqldump because it will attempt to output all 4PB of data and fill the drive long before it gets close to that, so I need to surgically remove the good stuff, destroy the db, and recreate it. I believe if I can do a dump for each domain_id record, then I will get most of the usable data out of it. This is what I am trying to use: mysqldump -u root --skip-opt -q --no-create-info --skip-add-drop-table --max_allowed_packet=1000000000 database table --where="domain_id=10" domains10.sql Using this I expect every row with the domain_id 10 to be exported. However, when I check the export, I am only getting 1 row, when however I look at the db, there are many many rows. It is as though the operator just finds one, then gives up. I have tried various operators. Using the < or I am able to get more of the data, but the export stops short at certain rows where the data has been compromised. With over 6000 to go through, I can't narrow down which rows are being affected in the export easily enough. So, what I need is an operator that will basically do what I thought = would do, simply give me an export of all records that match the specific field. Also note, the only way I got this DB even accessible is through an innodb force recovery 3. So I need to get this right, because after this is done, I have to drop the db in order to make mysql functional again. Looking forward to any helpful answers.

    Read the article

  • Trying to write a std::iterator : Compilation error

    - by Naveen
    I am trying to write an std::iterator for the CArray<Type,ArgType> MFC class. This is what I have done till now: template <class Type, class ArgType> class CArrayIterator : public std::iterator<std::random_access_iterator_tag, ArgType> { public: CArrayIterator(CArray<Type,ArgType>& array_in, int index_in = 0) : m_pArray(&array_in), m_index(index_in) { } void operator++() { ++m_index; } void operator++(int) { ++m_index; } void operator--() { --m_index; } void operator--(int) { --m_index; } void operator+=(int n) { m_index += n; } void operator-=(int n) { m_index -= n; } typename ArgType operator*() const{ return m_pArray->GetAt(m_index); } typename ArgType operator->() const { return m_pArray->GetAt(m_index); } bool operator==(const CArrayIterator& other) const { return m_pArray == other.m_pArray && m_index == other.m_index; } bool operator!=(const CArrayIterator& other) const { return ! (operator==(other)); } private: CArray<Type,ArgType>* m_pArray; int m_index; }; I also provided two helper functions to create the iterators like this: template<class Type, class ArgType> CArrayIterator<Type,ArgType> make_begin(CArray<Type,ArgType>& array_in) { return CArrayIterator<Type,ArgType>(array_in, 0); } template<class Type, class ArgType> CArrayIterator<Type,ArgType> make_end(CArray<Type,ArgType>& array_in) { return CArrayIterator<Type,ArgType>(array_in, array_in.GetSize()); } To test the code, I wrote a simple class A and tried to use it like this: class A { public: A(int n): m_i(n) { } int get() const { return m_i; } private: int m_i; }; struct Test { void operator()(A* p) { std::cout<<p->get()<<"\n"; } }; int main(int argc, char **argv) { CArray<A*, A*> b; b.Add(new A(10)); b.Add(new A(20)); std::for_each(make_begin(b), make_end(b), Test()); return 0; } But when I compile this code, I get the following error: Error 4 error C2784: 'bool std::operator <(const std::_Tree<_Traits &,const std::_Tree<_Traits &)' : could not deduce template argument for 'const std::_Tree<_Traits &' from 'CArrayIterator' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility 1564 Vs8Console Can anybody throw some light on what I am doing wrong and how it can be corrected? I am using VC9 compiler if it matters.

    Read the article

  • C++ -- Why should we use operator -> to access member functions of a SmartPtr?

    - by q0987
    Hello all, The question is given in the last two lines of code. template<class T> // template class for smart class SmartPtr { // pointers-to-T objects public: SmartPtr(T* realPtr = 0); T* operator->() const; T& operator*() const; T* Detach( void ) { T* pData = pointee; pointee = NULL; return pData; } private: T *pointee; ... }; class TestClass {} SmartPtr<TestClass> sPtr(new TestClass); TestClass* ptrA = sPtr->Detach(); // why I always see people use this method to access member functions of a Smart pointer. We can use sPtr-> b/c we have defined operator->() in SmartPtr. TestClass* ptrB = sPtr.Detach(); // Question: Is this a valid C++ way? If not, why? Thank you

    Read the article

  • infix operation to postfix using stacks

    - by Chris De La O
    We are writing a program that needs to convert an infix operation (4 5/3) to postfix (4 5 3 / ) using stacks. however my convert to postfix does not work as it doesnt not output the postFix array that is supposed to store the conversion from infix notation to postfix notation. here is the code for the convertToPostix fuction. //converts infix expression to postfix expression void ArithmeticExpression::convertToPostfix(char *const inFix, char *const postFix) { //create a stack2 object named cow Stack2<char> cow; cout<<postFix; char thing = '('; //push a left parenthesis onto the stack cow.push(thing); //append a right parenthesis to the end of inFix array strcat(inFix, ")"); int i = 0;//declare an int that will control posFix position //if the stack is not empty if (!cow.isEmpty()) { //loop to run until the last character in inFix array for (int x = 0; inFix[x]!= '\0'; x++ ) { //if the inFix element is a digit if (isdigit(inFix[x])) { postFix[i]=inFix[x];//it is assigned to the next element in postFix array i++;//move on to next element in postFix } //if the inFix element is a left parenthesis else if (inFix[x]=='(') { cow.push(inFix[x]);//push it unto the stack } //if the inFix element is an operator else if (isOperator(inFix[x])) { char oper2 = inFix[x];//char variable holds inFix operator if (isOperator(cow.stackTop()))//if the top node in the stack is an operator { while (isOperator(cow.stackTop()))//and while the top node in the stack is an operator { char oper1 = cow.stackTop();//char variable holds node operator if(precedence( oper1, oper2))//if the node operator has higher presedence than node operator { postFix[i] = cow.pop();//we pop such operator and insert it in postFix array's next element cow.push(inFix[x]);//and push inFix operator unto the stack i++;//move to the next element in posFix } } } //if the top node is not an operator //we push the current inFix operator unto the top of the stack else cow.push(inFix[x]); } //if the inFix element is a right parenthesis else if (inFix[x]==')') { //we pop everything in the stack and insert it in postFix //until we arrive at a left paranthesis while (cow.stackTop()!='(') { postFix[i] = cow.pop(); i++; } //we then pop and discard left parenthesis cow.pop(); } } postFix[i]='\0'; //print !!postFix array!! (not stack) print();//code for this is just cout<<postFix; }

    Read the article

  • What is the justification for Python's power operator associating to the right?

    - by Pieter Müller
    I am writing code to parse mathematical expression strings, and noticed that the order in which chained power operators are evaluated in Python differs from the order in Excel. From http://docs.python.org/reference/expressions.html: "Thus, in an unparenthesized sequence of power and unary operators, the operators are evaluated from right to left (this does not constrain the evaluation order for the operands): -1*2 results in -1."* This means that, in Python: 2**2**3 is evaluated as 2**(2**3) = 2**8 = 256 In Excel, it works the other way around: 2^2^3 is evaluated as (2^2)^3 = 4^3 = 64 I now have to choose an implementation for my own parser. The Excel order is easier to implement, as it mirrors the evaluation order of multiplication. I asked some people around the office what their gut feel was for the evaluation of 2^2^3 and got mixed responses. Does anybody know of any good reasons or conciderations in favour of the Python implementation? And if you don't have an answer, please comment with the result you get from gut feel - 64 or 256?

    Read the article

  • Stairway to T-SQL DML Level 8: Using the ROLLUP, CUBE and GROUPING SET operator in a GROUP BY Clause

    In this article I will be expanding on my discussion of the GROUP BY clause by exploring the ROLLUP, CUBE and GROUPING SETS operators. These additional GROUP BY operators make it is easy to have SQL Server create subtotals, grand totals, a superset of subtotals, as well as multiple aggregate groupings in a single SELECT statement. Local evaluation repository makes trying SQL Source Control simpleThe evaluation repository makes it easy to try SQL Source Control. Get started with the 28-day free trial.

    Read the article

  • When should I use String.Format or String.Concat instead of the concatenation operator?

    - by Kramii
    In C# it is possible to concatenate strings in several different ways: Using the concatenation operator: var newString = "The answer is '" + value + "'."; Using String.Format: var newString = String.Format("The answer is '{0}'.", value); Using String.Concat: var newString = String.Concat("The answer is '", value, "'."); What are the advantages / disadvantages of each of these methods? When should I prefer one over the others? The question arises because of a debate between developers. One never uses String.Format for concatenation - he argues that this is for formatting strings, not for concatenation, and that is is always unreadable because the items in the string are expressed in the wrong order. The other frequently uses String.Format for concatenation, because he thinks it makes the code easier to read, especially where there are several sets of quotes involved. Both these developers also use the concatenation operator and String.Builder, too.

    Read the article

  • Move constructor and assignment operator: why no default for derived classes?

    - by doublep
    Why there is default move constructor or assignment operator not created for derived classes? To demonstrate what I mean; having this setup code: #include <utility> struct A { A () { } A (A&&) { throw 0; } A& operator= (A&&) { throw 0; } }; struct B : A { }; either of the following lines throws: A x (std::move (A ()); A x; x = A (); but neither of the following does: B x (std::move (B ()); B x; x = B (); In case it matters, I tested with GCC 4.4.

    Read the article

  • In Ruby, can the coerce() method know what operator it is that requires the help to coerce?

    - by Jian Lin
    In Ruby, it seems that a lot of coerce() help can be done by def coerce(something) [self, something] end that's is, when 3 + rational is needed, Fixnum 3 doesn't know how to handle adding a Rational, so it asks Rational#coerce for help by calling rational.coerce(3), and this coerce instance method will tell the caller: # I know how to handle rational + something, so I will return you the following: [self, something] # so that now you can invoke + on me, and I will deal with Fixnum to get an answer So what if most operators can use this method, but not when it is (a - b) != (b - a) situation? Can coerce() know which operator it is, and just handle those special cases, while just using the simple [self, something] to handle all the other cases where (a op b) == (b op a) ? (op is the operator).

    Read the article

  • Why aren't operator conversions implicitly called for templated functions? (C++)

    - by John Gordon
    I have the following code: template <class T> struct pointer { operator pointer<const T>() const; }; void f(pointer<const float>); template <typename U> void tf(pointer<const float>); void g() { pointer<float> ptr; f(ptr); tf(ptr); } When I compile the code with gcc 4.3.3 I get a message (aaa.cc:17: error: no matching function for call to ‘tf(pointer<float>&)’) indicating that the compiler called 'operator pointer<const T>' for the non-templated function f(), but didn't for the templated function tf(). Why and is there any workaround short of overloading tf() with a const and non-const version? Thanks in advance for any help.

    Read the article

  • Where would I use a bitwise operator in JavaScript?

    - by J-P
    I've read this (http://stackoverflow.com/quest...), so I know what bitwise operators are but I'm still not clear on how one might use them... Can anyone offer any real-world examples of where a bitwise operator would be useful in JavaScript? Thanks. Edit: Just digging into the jQuery source I've found a couple of places where bitwise operators are used, for example: (only the & operator) // Line 2756: event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); // Line 2101 var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;

    Read the article

  • Is it possible to pass arithmetic operators to a method in java?

    - by drJames
    Right now I'm going to have to write a method that looks like this: public String Calculate(String Operator, Double Operand1, Double Operand2) { if (Operator.equals("+")) { return String.valueOf(Operand1 + Operand2); } else if (Operator.equals("-")) { return String.valueOf(Operand1 - Operand2); } else if (Operator.equals("*")) { return String.valueOf(Operand1 * Operand2); } else { return "error..."; } } It would be nice if I could write the code more like this: public String Calculate(String Operator, Double Operand1, Double Operand2) { return String.valueOf(Operand1 Operator Operand2); } So Operator would replace the Arithmetic Operators (+, -, *, /...) Does anyone know if something like this is possible in java?

    Read the article

  • Is it possible to pass arithmatic operators to a method in java?

    - by user349611
    Right now I'm going to have to write a method that looks like this: public String Calculate(String Operator, Double Operand1, Double Operand2) { if (Operator.equals("+")) { return String.valueOf(Operand1 + Operand2); } else if (Operator.equals("-")) { return String.valueOf(Operand1 - Operand2); } else if (Operator.equals("*")) { return String.valueOf(Operand1 * Operand2); } else { return "error..."; } } It would be nice if I could write the code more like this: public String Calculate(String Operator, Double Operand1, Double Operand2) { return String.valueOf(Operand1 Operator Operand2); } So Operator would replace the Arithmetic Operators (+, -, *, /...) Does anyone know if something like this is possible in java?

    Read the article

  • Use of .apply() with 'new' operator. Is this possible?

    - by Premasagar
    In JavaScript, I want to create an object instance (via the new operator), but pass an arbitrary number of arguments to the constructor. Is this possible? What I want to do is something like this (but the code below does not work): function Something(){ // init stuff } function createSomething(){ return new Something.apply(null, arguments); } var s = createSomething(a,b,c); // 's' is an instance of Something The Answer From the responses here, it became clear that there's no in-built way to call .apply() with the new operator. However, people suggested a number of really interesting solutions to the problem. My preferred solution was this one from Matthew Crumley (I've modified it to pass the arguments property): var createSomething = (function() { function F(args) { return Something.apply(this, args); } F.prototype = Something.prototype; return function() { return new F(arguments); } })();

    Read the article

  • Why can't I sort this container?

    - by Knowing me knowing you
    Please don't mind that there is no insert fnc and that data are hardcoded. The main purpouse of it is to correctly implement iterator for this container. //file Set.h #pragma once template<class T> class Set { template<class T> friend ostream& operator<<(ostream& out, const Set<T>& obj); private: T** myData_; std::size_t mySize_; std::size_t myIndex_; public: Set(); class iterator : public std::iterator<std::random_access_iterator_tag, T*> { private: T** itData_; public: iterator(T** obj) { itData_ = obj; } T operator*() const { return **itData_; } /*Comparing values of two iterators*/ bool operator<(const iterator& obj) { return **itData_ < **obj.itData_; } /*Substracting two iterators*/ difference_type operator-(const iterator& obj) { return itData_ - obj.itData_; } /*Moving iterator backward for value*/ iterator operator-(const int value) { return itData_ - value; } /*Adding two iterators*/ difference_type operator+(const iterator& obj) { return itData_ + obj.itData_; } /*Moving iterator forward for value*/ iterator operator+(const int value) { return itData_ + value; } bool operator!=(const iterator& obj) { return (itData_ != obj.itData_); } bool operator==(const iterator& obj) { return (itData_ == obj.itData_); } T** operator++() { return ++itData_; } T** operator--() { return --itData_; } }; iterator begin() const { return myData_; } iterator end() const { return myData_ + myIndex_; } }; template<class T> ostream& operator<<(ostream& out, const Set<T>& obj) { for (int i = 0;i < 3; ++i) { out << *obj.myData_[i] << "\n"; } return out; } //file Set_impl.h #pragma once #include "stdafx.h" #include "Set.h" template<class T> Set<T>::Set() { mySize_ = 3; myIndex_ = 3; myData_ = new T*[mySize_]; myData_[0] = new T(3); myData_[1] = new T(1); myData_[2] = new T(2); } //main include "stdafx.h" #include "Set_impl.h" int _tmain(int argc, _TCHAR* argv[]) { Set<int> a; Set<int>::iterator beg_ = a.begin(); Set<int>::iterator end_ = a.end(); std::sort(beg_,end_);//WONT SORT THIS RANGE cin.get(); return 0; } Why sort can't accept this iterators even though I've provided all operators needed for sort to work? I think the best way to check what's going on is to paste this code and run it first. Thanks

    Read the article

  • How to write a streaming 'operator<<' that can take arbitary containers (of type 'X')?

    - by Drew Dormann
    I have a C++ class "X" which would have special meaning if a container of them were to be sent to a std::ostream. I originally implemented it specifically for std::vector<X>: std::ostream& operator << ( std::ostream &os, const std::vector<X> &c ) { // The specialized logic here expects c to be a "container" in simple // terms - only that c.begin() and c.end() return input iterators to X } If I wanted to support std::ostream << std::deque<X> or std::ostream << std::set<X> or any similar container type, the only solution I know of is to copy-paste the entire function and change only the function signature! Is there a way to generically code operator << ( std::ostream &, const Container & )? ("Container" here would be any type that satisfies the commented description above.)

    Read the article

  • Passing arguments to objects created using the new operator?

    - by Abhijit
    Hi guys, I have a small C++ problem to which I don't know the best solution. I have two classes A and B as follows: class A { int n; B* b; public: A(int num): n(num) { b = new B[n]; for (int i = 0; i < n; i++) { b[i].setRef(this); } } ~A() { delete [] b; } }; class B { A* a; public: B() { } B(A* aref) { a = aref; } void setRef(A* aref) { a = aref; } }; I am creating an object of class A by passing to its constructor the number of objects of class B I want to be created. I want every object of class B to hold a pointer to the class A object that creates it. I think the best way to do this would be by passing the pointer to the class A object as a constructor argument to the class B object. However, since I'm using the new operator, the no-args constructor for class B is called. As a result, the only solution I can see here is calling the setRef(A*) method for every object of class B after it has been constructed using the new operator. Is there a better solution/design pattern that would be more applicable here? Would using placement new for class B be a better solution? Thanks in advance for your help.

    Read the article

  • Is Perl's flip-flop operator bugged? It has global state, how can I reset it?

    - by Evan Carroll
    I'm dismayed. Ok, so this was probably the most fun perl bug I've ever found. Even today I'm learning new stuff about perl. Essentially, the flip-flop operator .. which returns false until the left-hand-side returns true, and then true until the right-hand-side returns false keep global state (or that is what I assume.) My question is can I reset it, (perhaps this would be a good addition to perl4-esque hardly ever used reset())? Or, is there no way to use this operator safely? I also don't see this (the global context bit) documented anywhere in perldoc perlop is this a mistake? Code use feature ':5.10'; use strict; use warnings; sub search { my $arr = shift; grep { !( /start/ .. /never_exist/ ) } @$arr; } my @foo = qw/foo bar start baz end quz quz/; my @bar = qw/foo bar start baz end quz quz/; say 'first shot - foo'; say for search \@foo; say 'second shot - bar'; say for search \@bar; Spoiler $ perl test.pl first shot foo bar second shot

    Read the article

  • In this example where is the C++ assignment operator used rather than the copy constructor ?

    - by Bill Forster
    As part of an ongoing process of trying to upgrade my C++ skills, I am trying to break some old habits. My old school C programmer inclination is to write this; void func( Widget &ref ) { Widget w; // default constructor int i; for( i=0; i<10; i++ ) { w = ref; // assignment operator // do stuff that modifies w } } This works well. But I think the following is closer to best practice; void func( Widget &ref ) { for( int i=0; i<10; i++ ) { Widget w = ref; // ?? // do stuff that modifies w } } With my Widget class at least, this works fine. But I don't fully understand why. I have two theories; 1) The copy constructor runs 10 times. 2) The copy constructor runs once then the assignment operator runs 9 times. Both of these trouble me a little. 2) in particular seems artificial and wrong. Is there a third possibility that I am missing ?

    Read the article

  • is there something equivalent to 'Address of' or offset operator in .net?

    - by Gio
    We have nested stuctures as such, used as an interface for some device drivers. On occasion we have to update individual elements. An 'address of' operator would be helpful, but an 'offset' function or operator is what I'm really looking for, but not sure how to go about it. In other words, how far is structureN.elementX away from the start of the structure in bytes? [StructLayout(LayoutKind.Sequential)] public struct s1 { UInt16 elem1; UInt16 elem2; UInt16 elem3; } [StructLayout(LayoutKind.Sequential)] public struct s2 { UInt16 elem1; UInt16 elem2; UInt16 elem3; } [StructLayout(LayoutKind.Sequential)] public struct driver { public S1 s1; public S2 s2; } For instance we need to send the device driver some data to update driver.s1.elem3, by way of providing an offset address, data block and length. We would update our local copy, then call the device api with the afore mentioned data. Not sure I have to do this with 'unsafe' method calls. Any help?

    Read the article

  • Working with Reporting Services Filters–Part 1

    - by smisner
    There are two ways that you can filter data in Reporting Services. The first way, which usually provides a faster performance, is to use query parameters to apply a filter using the WHERE clause in a SQL statement. In that case, the structure of the filter depends upon the syntax recognized by the source database. Another way to filter data in Reporting Services is to apply a filter to a dataset, data region, or a group. Using this latter method, you can even apply multiple filters. However, the use of filter operators or the setup of multiple filters is not always obvious, so in this series of posts, I'll provide some more information about the configuration of filters. First, why not use query parameters exclusively for filtering? Here are a few reasons: You might want to apply a filter to part of the report, but not all of the report. Your dataset might retrieve data from a stored procedure, and doesn't allow you to pass a query parameter for filtering purposes. Your report might be set up as a snapshot on the report server and, in that case, cannot be dynamically filtered based on a query parameter. Next, let's look at how to set up a report filter in general. The process is the same whether you are applying the filter to a dataset, data region, or a group. When you go to the Filters page in the Properties dialog box for whichever of these items you selected (dataset, data region, group), you click the Add button to create a new filter. The interface looks like this: The Expression field is usually a field in the dataset, so to make it easier for you to make a selection,the drop-down list displays all of the current dataset fields. But notice the expression button to the right, which means that you can set up any type of expression-not just a dataset field. To the right of the expression button, you'll find a data type drop-down list. It's important to specify the correct data type for the field or expression you're using. Now for the operators. Here's a list of the options that you have: This Operator Performs This Action =, <>, >, >=, <, <=, Like Compares expression to value Top N, Bottom N Compares expression to Top (Bottom) set of N values (N = integer) Top %, Bottom % Compares expression to Top (Bottom) N percent of values (N = integer or float) Between Determines whether expression is between two values, inclusive In Determines whether expression is found in list of values Last, the Value is what you're comparing to the expression using the operator. The construction of a filter using some operators (=, <>, >, etc.) is fairly simple. If my dataset (for AdventureWorks data) has a Category field, and I have a parameter that prompts the user for a single category, I can set up a filter like this: Expression Data Type Operator Value [Category] Text = [@Category] But if I set the parameter to accept multiple values, I need to change the operator from = to In, just as I would have to do if I were using a query parameter. The parameter expression, [@Category], which translates to =Parameters!Category.Value, doesn’t need to change because it represents an array as soon as I change the parameter to allow multiple values. The “In” operator requires an array. With that in mind, let’s consider a variation on Value. Let’s say that I have a parameter that prompts the user for a particular year – and for simplicity’s sake, this parameter only allows a single value, and I have an expression that evaluates the previous year based on the user’s selection. Then I want to use these two values in two separate filters with an OR condition. That is, I want to filter either by the year selected OR by the year that was computed. If I create two filters, one for each year (as shown below), then the report will only display results if BOTH filter conditions are met – which would never be true. Expression Data Type Operator Value [CalendarYear] Integer = [@Year] [CalendarYear] Integer = =Parameters!Year.Value-1 To handle this scenario, we need to create a single filter that uses the “In” operator, and then set up the Value expression as an array. To create an array, we use the Split function after creating a string that concatenates the two values (highlighted in yellow) as shown below. Expression Data Type Operator Value =Cstr(Fields!CalendarYear.Value) Text In =Split( CStr(Parameters!Year.Value) + ”,” + CStr(Parameters!Year.Value-1) , “,”) Note that in this case, I had to apply a string conversion on the year integer so that I could concatenate the parameter selection with the calculated year. Pay attention to the second argument of the Split function—you must use a comma delimiter for the result to work correctly with the In operator. I also had to change the Expression value from [CalendarYear] (or =Fields!CalendarYear.Value) so that the expression would return a string that I could compare with the values in the string array. More fun with filter expressions in future posts!

    Read the article

  • C++ templates - matrix class

    - by lastOfMohicans
    Hi I'm learning templates in C++ so I decied to write matrix class which would be a template class. In Matrix.h file I wrote #pragma once #include "stdafx.h" #include <vector> using namespace std; template<class T> class Matrix { public: Matrix(); ~Matrix(); GetDataVector(); SetDataVector(vector<vector<T>> dataVector); bool operator == (Matrix* matrix); bool operator < (Matrix* matrix); bool operator <= (Matrix* matrix); bool operator > (Matrix* matrix); bool operator >= (Matrix* matrix); Matrix* operator + (Matrix* matrix); Matrix* operator - (Matrix* matrix); Matrix* operator * (Matrix* matrix); private: vector<vector<T>> datavector; int columns,rows; }; In Matrix cpp Visual Stuio automaticlly generated code for default constructors #include "StdAfx.h" #include "Matrix.h" Matrix::Matrix() { } Matrix::~Matrix() { } However if I want to compile this I get an error 'Matrix' : use of class template requires template argument list The error are in file Matrix.cpp in default constructors What may be the problem ??

    Read the article

  • C++ STL question related to insert iterators and overloaded operators

    - by rshepherd
    #include <list> #include <set> #include <iterator> #include <algorithm> using namespace std; class MyContainer { public: string value; MyContainer& operator=(const string& s) { this->value = s; return *this; } }; int main() { list<string> strings; strings.push_back("0"); strings.push_back("1"); strings.push_back("2"); set<MyContainer> containers; copy(strings.begin(), strings.end(), inserter(containers, containers.end())); } The preceeding code does not compile. In standard C++ fashion the error output is verbose and difficult to understand. The key part seems to be this... /usr/include/c++/4.4/bits/stl_algobase.h:313: error: no match for ‘operator=’ in ‘__result.std::insert_iterator::operator* [with _Container = std::set, std::allocator ]() = __first.std::_List_iterator::operator* [with _Tp = std::basic_string, std::allocator ]()’ ...which I interpet to mean that the assignment operator needed is not defined. I took a look at the source code for insert_iterator and noted that it has overloaded the assignment operator. The copy algorithm must uses the insert iterators overloaded assignment operator to do its work(?). I guess that because my input iterator is on a container of strings and my output iterator is on a container of MyContainers that the overloaded insert_iterator assignment operator can no longer work. This is my best guess, but I am probably wrong. So, why exactly does this not work and how can I accomplish what I am trying to do?

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >