Search Results

Search found 511 results on 21 pages for 'overloading'.

Page 13/21 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • MS SQL tuning tools for finding overload

    - by SkyFox
    I use MS SQL server as a DBMS for my very big corporate DB (with different financial data). And some times my system go down. I don't understand why. What programs/tools I can use for finding process/program/thread, that overload my SQL-server? Thanks for all answers!

    Read the article

  • Prolog: declaring an operator

    - by B K
    I have defined ! (factorial) function and registered it as arithmetic function and an operator, so that I can execute: A is 6!. Now I'd like to define !! (factorial of odd numbers), but the same way - writing clauses, registering arithmetic_function and operator, calling A is 7!! - results in SyntaxError: Operator expected How should I, if possible, register !! operator ? Yes, I realize, ! is normally the cut.

    Read the article

  • C++: Overload != When == Overloaded

    - by Mark W
    Say I have a class where I overloaded the operator == as such: Class A { ... public: bool operator== (const A &rhs) const; ... }; ... bool A::operator== (const A &rhs) const { .. return isEqual; } I already have the operator == return the proper Boolean value. Now I want to extend this to the simple opposite (!=). I would like to call the overloaded == operator and return the opposite, i.e. something of the nature bool A::operator!= (const A &rhs) const { return !( this == A ); } Is this possible? I know this will not work, but it exemplifies what I would like to have. I would like to keep only one parameter for the call: rhs. Any help would be appreciated, because I could not come up with an answer after several search attempts.

    Read the article

  • Overload and hide methods in Java

    - by Marco
    Hi, i have an abstract class BaseClass with a public insert() method: public abstract class BaseClass { public void insert(Object object) { // Do something } } which is extended by many other classes. For some of those classes, however, the insert() method must have additional parameters, so that they instead of overriding it I overload the method of the base class with the parameters required, for example: public class SampleClass extends BaseClass { public void insert(Object object, Long param){ // Do Something } } Now, if i instantiate the SampleClass class, i have two insert() methods: SampleClass sampleClass = new SampleClass(); sampleClass.insert(Object object); sampleClass.insert(Object object, Long param); what i'd like to do is to hide the insert() method defined in the base class, so that just the overload would be visible: SampleClass sampleClass = new SampleClass(); sampleClass.insert(Object object, Long param); Could this be done in OOP?

    Read the article

  • Overload with different return type in java?

    - by nunos
    So, I am just starting Java and, even though I have looked in some question about it here at stackoverflow.com and elsewhere, haven't been able to find a straightforward answer to why isn't possible to overload a function just by changing the return type. Why is it so? Will that provably change in a future version of Java? By the way, just for reference, is this possible in C++? Thanks.

    Read the article

  • template; operator (int)

    - by Oops
    Hi, regarding my Point struct already mentioned here: http://stackoverflow.com/questions/2794369/template-class-ctor-against-function-new-c-standard is there a chance to replace the function toint() with a cast-operator (int)? namespace point { template < unsigned int dims, typename T > struct Point { T X[ dims ]; //umm??? template < typename U > Point< dims, U > operator U() const { Point< dims, U > ret; std::copy( X, X + dims, ret.X ); return ret; } //umm??? Point< dims, int > operator int() const { Point<dims, int> ret; std::copy( X, X + dims, ret.X ); return ret; } //OK Point<dims, int> toint() { Point<dims, int> ret; std::copy( X, X + dims, ret.X ); return ret; } }; //struct Point template < typename T > Point< 2, T > Create( T X0, T X1 ) { Point< 2, T > ret; ret.X[ 0 ] = X0; ret.X[ 1 ] = X1; return ret; } }; //namespace point int main(void) { using namespace point; Point< 2, double > p2d = point::Create( 12.3, 34.5 ); Point< 2, int > p2i = (int)p2d; //äähhm??? std::cout << p2d.str() << std::endl; char c; std::cin >> c; return 0; } I think the problem is here that C++ cannot distinguish between different return types? many thanks in advance. regards Oops

    Read the article

  • Is it possible to implement events in C++?

    - by acidzombie24
    I wanted to implement a C# event in C++ just to see if i could do it. I got stuck, i know the bottom is wrong but what i realize my biggest problem is... How do i overload the () operator to be whatever is in T in this case int func(float)? I cant? can i? Can i implement a good alternative? #include <deque> using namespace std; typedef int(*MyFunc)(float); template<class T> class MyEvent { deque<T> ls; public: MyEvent& operator +=(T t) { ls.push_back(t); return *this; } }; static int test(float f){return (int)f; } int main(){ MyEvent<MyFunc> e; e += test; }

    Read the article

  • C++ operator[] syntax.

    - by Lanissum
    Just a quick syntax question. I'm writing a map class (for school). If I define the following operator overload: template<typename Key, typename Val> class Map {... Val* operator[](Key k); What happens when a user writes: Map<int,int> myMap; map[10] = 3; Doing something like that will only overwrite a temporary copy of the [null] pointer at Key k. Is it even possible to do: map[10] = 3; printf("%i\n", map[10]); with the same operator overload?

    Read the article

  • delegating into private parts

    - by FredOverflow
    Sometimes, C++'s notion of privacy just baffles me :-) class Foo { struct Bar; Bar* p; public: Bar* operator->() const { return p; } }; struct Foo::Bar { void baz() { std::cout << "inside baz\n"; } }; int main() { Foo::Bar b; // error: 'struct Foo::Bar' is private within this context Foo f; f->baz(); // fine } Since Foo::Bar is private, I cannot declare b in main. Yet I can call methods from Foo::Bar just fine. Why the hell is this allowed? Was that an accident or by design?

    Read the article

  • Backward compatibility in dlls

    - by michaelleuzinger
    Hi I do have three dlls. a.dll - released many years ago b.dll - released not so many years c.dll - released shortly Each one contains the same function - unfortunatelly with different parameters. so I do have the following Methods aMethod(param1) aMethod(param1, param2) aMethod(param1, param2, param3) My Task is to make a new dll (or new dlls) wich is backward compatible. But as far as I've learned from Google there is no possibility to overload methods in a dll. Does any one have a tip how I can solve this problem elegantly? -- Michael

    Read the article

  • does overload operator-> a compile time action?

    - by Brent
    when I tried to compile the code: struct S { void func2() {} }; class O { public: inline S* operator->() const; private: S* ses; }; inline S* O::operator->() const { return ses; } int main() { O object; object->func(); return 0; } there is a compile error reported: D:\code>g++ operatorp.cpp -S -o operatorp.exe operatorp.cpp: In function `int main()': operatorp.cpp:27: error: 'struct S' has no member named 'func' it seems that invoke the overloaded function of "operator-" is done during compile time? I'd add "-S" option for compile only.

    Read the article

  • Detect if class has overloaded function fails on Comeau compiler

    - by Frank
    Hi Everyone, I'm trying to use SFINAE to detect if a class has an overloaded member function that takes a certain type. The code I have seems to work correctly in Visual Studio and GCC, but does not compile using the Comeau online compiler. Here is the code I'm using: #include <stdio.h> //Comeau doesnt' have boost, so define our own enable_if_c template<bool value> struct enable_if_c { typedef void type; }; template<> struct enable_if_c< false > {}; //Class that has the overloaded member function class TestClass { public: void Func(float value) { printf( "%f\n", value ); } void Func(int value) { printf( "%i\n", value ); } }; //Struct to detect if TestClass has an overloaded member function for type T template<typename T> struct HasFunc { template<typename U, void (TestClass::*)( U )> struct SFINAE {}; template<typename U> static char Test(SFINAE<U, &TestClass::Func>*); template<typename U> static int Test(...); static const bool Has = sizeof(Test<T>(0)) == sizeof(char); }; //Use enable_if_c to only allow the function call if TestClass has a valid overload for T template<typename T> typename enable_if_c<HasFunc<T>::Has>::type CallFunc(TestClass &test, T value) { test.Func( value ); } int main() { float value1 = 0.0f; int value2 = 0; TestClass testClass; CallFunc( testClass, value1 ); //Should call TestClass::Func( float ) CallFunc( testClass, value2 ); //Should call TestClass::Func( int ) } The error message is: no instance of function template "CallFunc" matches the argument list. It seems that HasFunc::Has is false for int and float when it should be true. Is this a bug in the Comeau compiler? Am I doing something that's not standard? And if so, what do I need to do to fix it?

    Read the article

  • Creating methods with infinite overloads ? (.NET)

    - by MarceloRamires
    In C# you can do this: foo = string.Format("{0} {1} {2} {3} ...", "aa", "bb", "cc" ...); This method Format() accepts infinite parameters, being the first one how the string should be formatted and the rest are values to be put in the string. Today I've come to a situation where I had to get a set of strings and test them, then I remembered this language functionality, but I had no clue. After a few unsuccessful web searches, I've realised it would be more prudent to just get an array, which didn't make me quite satisfied. Q: How do I make a function that accepts infinite parameters? And how do I use it ?

    Read the article

  • how to call operator () in c++

    - by anish
    in c++ i have following code class Foobar{ public: Foobar * operator()(){ return new Foobar; } My quesion is how to call the (); if i do Foobar foo() the constructor gets called i am confused about behaviour of () can some explain me

    Read the article

  • Is it possible to supply template parameters when calling operator()?

    - by Paul
    I'd like to use a template operator() but am not sure if it's possible. Here is a simple test case that won't compile. Is there something wrong with my syntax, or is this simply not possible? struct A { template<typename T> void f() { } template<typename T> void operator()() { } }; int main() { A a; a.f<int>(); // This compiles. a.operator()<int>(); // This compiles. a<int>(); // This won't compile. return 0; }

    Read the article

  • overload == (and != , of course) operator, can I bypass == to determine whether the object is null

    - by LLS
    Hello, when I try to overload operator == and != in C#, and override Equal as recommended, I found I have no way to distinguish a normal object and null. For example, I defined a class Complex. public static bool operator ==(Complex lhs, Complex rhs) { return lhs.Equals(rhs); } public static bool operator !=(Complex lhs, Complex rhs) { return !lhs.Equals(rhs); } public override bool Equals(object obj) { if (obj is Complex) { return (((Complex)obj).Real == this.Real && ((Complex)obj).Imaginary == this.Imaginary); } else { return false; } } But when I want to use if (temp == null) When temp is really null, some exception happens. And I can't use == to determine whether the lhs is null, which will cause infinite loop. What should I do in this situation. One way I can think of is to us some thing like Class.Equal(object, object) (if it exists) to bypass the == when I do the check. What is the normal way to solve the problem?

    Read the article

  • C++: How to make comparison function for char arrays?

    - by Newbie
    Is this possible? i get weird error message when i put char as the type: inline bool operator==(const char *str1, const char *str2){ // ... } Error message: error C2803: 'operator ==' must have at least one formal parameter of class type ... which i dont understand at all. I was thinking if i could directly compare stuff like: const char *str1 = "something"; const char *str2 = "something else"; const char str3[] = "lol"; // not sure if this is same as above and then compare: if(str1 == str2){ // ... } etc. But i also want it to work with: char *str = new char[100]; and: char *str = (char *)malloc(100); I am assuming every char array i use this way would end in NULL character, so the checking should be possible, but i understand it can be unsafe etc. I just want to know if this is possible to do, and how.

    Read the article

  • question regarding "this" pointer in c++

    - by sil3nt
    hello there, i have been given class with int variables x and y in private, and an operator overload function, class Bag{ private: int x; int y; public: Bag(); ~Bag(); //....... //.....etc }; Bag operator+ (Bag new) const{ Bag result(*this); //what does this mean? result.x += new.x; result.y += new.y; } What is the effect of having "Bag result(*this);" there?.

    Read the article

  • Java: If I overwrite the .equals method, can I still test for reference equality with ==?

    - by shots fired
    I have the following situation: I need to sort trees based by height, so I made the Tree's comparable using the height attribute. However, I was also told to overwrite the equals and hashCode methods to avoid unpredictable behaviour. Still, sometimes I may want to compare the references of the roots or something along those lines using ==. Is that still possible or does the == comparison call the equals method?

    Read the article

  • Overload the behavior of count() when called on certain objects

    - by Tom
    In PHP 5, you can use magic methods, overload some classes, etc. In C++, you can implement functions that exist is STL as long as the argument types are different. Is there a way to do this in PHP? An example of what I'd like to do is this: class a { function a() { $this->list = array("1", "2"); } } $blah = new a(); count($blah); I would like blah to return 2. IE count the values of a specific array in the class. So in C++, the way I would do this might look like this: int count(a varName) { return count(varName->list); } Basically, I am trying to simplify data calls for a large application so I can call do this: count($object); rather than count($object->list); The list is going to be potentially a list of objects so depending on how it's used, it could be really nasty statement if someone has to do it the current way: count($object->list[0]->list[0]->list); So, can I make something similar to this: function count(a $object) { count($object->list); } I know PHP's count accepts a mixed var, so I don't know if I can override an individual type.

    Read the article

  • Returning a struct from a class method

    - by tree
    I have a header file that looks something like the following: class Model { private: struct coord { int x; int y; } xy; public: .... coord get() const { return xy; } }; And in yet another file (assume ModelObject exists): struct c { int x; int y; void operator = (c &rhs) { x = rhs.x; y = rhs.y; }; } xy; xy = ModelObject->get(); The compiler throws an error that says there is no known covnersion from coord to c. I believe it is because it doesn't know about coord type because it is declared inside of a class header. I can get around that by declaring the struct outside of the class, but I was wondering if it is possible to do the way I am, or is this generally considered bad practice

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >