Search Results

Search found 3340 results on 134 pages for 'comma operator'.

Page 7/134 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • copy C'tor with operator= | C++

    - by user2266935
    I've got this code here: class DerivedClass : public BaseClass { SomeClass* a1; Someclass* a2; public: //constructors go here ~DerivedClass() { delete a1; delete a2;} // other functions go here .... }; My first question is as follows: Can I write an "operator=" to "DerivedClass" ? (if your answer is yes, could you show me how?) My second question is: If the answer to the above is yes, could you show me how to make an "copy c'tor" using the "operator=" that you wrote beforehand (if that is even possible)? Your help would be much appreciated !

    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

  • null-coalescing operator or conditional operator

    - by rkrauter
    Which coding style do you prefer: object o = new object(); //string s1 = o ?? "Tom"; // Cannot implicitly convert type 'object' to 'string' CS0266 string s3 = Convert.ToString(o ?? "Tom"); string s2 = (o != null) ? o.ToString() : "Tom"; s2 or s3? Is it possible to make it shorter? s1 does not obviously work.

    Read the article

  • Grouping a comma separated value on common data [closed]

    - by Ankit
    I have a table with col1 id int, col2 as varchar (comma separated values) and column 3 for assigning group to them. Table looks like col1 col2 group .............................. 1 2,3,4 2 5,6 3 1,2,5 4 7,8 5 11,3 6 22,8 This is only the sample of real data, now I have to assign a group no to them in such a way that output looks like col1 col2 group .............................. 1 2,3,4 1 2 5,6 1 3 1,2,5 1 4 7,8 2 5 11,3 1 6 22,8 2 The logic for assigning group no is that every similar comma separated value of string in col2 have to be same group no as every where in col2 where '2' is there it has to be same group no but the complication is that 2,3,4 are together so they all three int value if found in any where in col2 will be assigned same group. The major part is 2,3,4 and 1,2,5 both in col2 have 2 so all int 1,2,3,4,5 have to assign same group no. Tried store procedure with match against on col2 but not getting desired result Most imp (I can't use normalization, because I can't afford to make new table from my original table which have millions of records), even normalization is not helpful in my context. This question is also on stackoverflow with bounty on this link Achieved so far:- I have set the group column auto increment and then wrote this procedure:- BEGIN declare cil1_new,col2_new,group_new int; declare done tinyint default 0; declare group_new varchar(100); declare cur1 cursor for select col1,col2,`group` from company ; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1; open cur1; REPEAT fetch cur1 into col1_new,col2_new,group_new; update company set group=group_new where match(col2) against(concat("'",col2_new,"'")); until done end repeat; close cur1; select * from company; END This procedure is working, no syntax mistake but the problem is that I am not achieving the desired result exactly.

    Read the article

  • Working with Reporting Services Filters – Part 2: The LIKE Operator

    - by smisner
    In the first post of this series, I introduced the use of filters within the report rather than in the query. I included a list of filter operators, and then focused on the use of the IN operator. As I mentioned in the previous post, the use of some of these operators is not obvious, so I'm going to spend some time explaining them as well as describing ways that you can use report filters in Reporting Services in this series of blog posts. Now let's look at the LIKE operator. If you write T-SQL queries, you've undoubtedly used the LIKE operator to produce a query using the % symbol as a wildcard for multiple characters like this: select * from DimProduct where EnglishProductName like '%Silver%' And you know that you can use the _ symbol as a wildcard for a single character like this: select * from DimProduct where EnglishProductName like '_L Mountain Frame - Black, 4_'   So when you encounter the LIKE operator in a Reporting Services filter, you probably expect it to work the same way. But it doesn't. You use the * symbol as a wildcard for multiple characters as shown here: Expression Data Type Operator Value [EnglishProductName] Text Like *Silver* Note that you don’t have to include quotes around the string that you use for comparison. Books Online has an example of using the % symbol as a wildcard for a single character, but I have not been able to successfully use this wildcard. If anyone has a working example, I’d love to see it!

    Read the article

  • Which to use - "operator new" or "operator new[]" - to allocate a block of raw memory in C++?

    - by sharptooth
    My C++ program needs a block of uninitialized memory. In C I would use malloc() and later free(). In C++ I can either call ::operator new or ::operator new[] and ::operator delete or operator delete[] respectively later. Looks like both ::operator new and ::operator new[] have exactly the same signature and exactly the same behavior. The same for ::operator delete and ::operator delete[]. The only thing I shouldn't do is pairing operator new with operator delete[] and vice versa - undefined behavior. Other than that which pair do I choose and why?

    Read the article

  • C++ operator new, object versions, and the allocation sizes

    - by mizubasho
    Hi. I have a question about different versions of an object, their sizes, and allocation. The platform is Solaris 8 (and higher). Let's say we have programs A, B, and C that all link to a shared library D. Some class is defined in the library D, let's call it 'classD', and assume the size is 100 bytes. Now, we want to add a few members to classD for the next version of program A, without affecting existing binaries B or C. The new size will be, say, 120 bytes. We want program A to use the new definition of classD (120 bytes), while programs B and C continue to use the old definition of classD (100 bytes). A, B, and C all use the operator "new" to create instances of D. The question is, when does the operator "new" know the amount of memory to allocate? Compile time or run time? One thing I am afraid of is, programs B and C expect classD to be and alloate 100 bytes whereas the new shared library D requires 120 bytes for classD, and this inconsistency may cause memory corruption in programs B and C if I link them with the new library D. In other words, the area for extra 20 bytes that the new classD require may be allocated to some other variables by program B and C. Is this assumption correct? Thanks for your help.

    Read the article

  • Reflection and Operator Overloads in C#

    - by TenshiNoK
    Here's the deal. I've got a program that will load a given assembly, parse through all Types and their Members and compile a TreeView (very similar to old MSDN site) and then build HTML pages for each node in the TreeView. It basically takes a given assembly and allows the user to create their own MSDN-like library for it for documentation purposes. Here's the problem I've run into: whenever an operator overload is encounted in a defined class, reflection returns that as a "MethodInfo" with the name set to something like "op_Assign" or "op_Equality". I want to be able to capture these and list them properly, but I can't find anything in the MethodInfo object that is returned to accurately identify that I'm looking at an operator. I definitely don't want to just capture everything that starts with "op_", since that will most certainly (at some point) will pick up a method it's not supposed to. I know that other methods and properties that are "special cases" like this one have the "IsSpecialName" property set, but appearantly that's not the case with operators. I've been scouring the 'net and wracking my brain to two days trying to figure this one out, so any help will be greatly appreciated.

    Read the article

  • PHP ternary operator

    - by thecoshman
    ($DAO->get_num_rows() == 1) ? echo("is") : echo("are"); This dose not seem to be working for me,I get an error "Unexpected T_ECHO" I have tried it with out the brackets around the conditional. Am I just not able to use a ternary operator in this way? The $DAO-get_num_rows() returns an integer value. Thanks

    Read the article

  • C# Nested Property Accessing overloading OR Sequential Operator Overloading

    - by Tim
    Hey, I've been searching around for a solution to a tricky problem we're having with our code base. To start, our code resembles the following: class User { int id; int accountId; Account account { get { return Account.Get(accountId); } } } class Account { int accountId; OnlinePresence Presence { get { return OnlinePresence.Get(accountId); } } public static Account Get(int accountId) { // hits a database and gets back our object. } } class OnlinePresence { int accountId; bool isOnline; public static OnlinePresence Get(int accountId) { // hits a database and gets back our object. } } What we're often doing in our code is trying to access the account Presence of a user by doing var presence = user.Account.Presence; The problem with this is that this is actually making two requests to the database. One to get the Account object, and then one to get the Presence object. We could easily knock this down to one request if we did the following : var presence = UserPresence.Get(user.id); This works, but sort of requires developers to have an understanding of the UserPresence class/methods that would be nice to eliminate. I've thought of a couple of cool ways to be able to handle this problem, and was wondering if anyone knows if these are possible, if there are other ways of handling this, or if we just need to think more as we're coding and do the UserPresence.Get instead of using properties. Overload nested accessors. It would be cool if inside the User class I could write some sort of "extension" that would say "any time a User object's Account property's Presence object is being accessed, do this instead". Overload the . operator with knowledge of what comes after. If I could somehow overload the . operator only in situations where the object on the right is also being "dotted" it would be great. Both of these seem like things that could be handled at compile time, but perhaps I'm missing something (would reflection make this difficult?). Am I looking at things completely incorrectly? Is there a way of enforcing this that removes the burden from the user of the business logic? Thanks! Tim

    Read the article

  • Java operator precedence guidelines

    - by trashgod
    Misunderstanding Java operator precedence is a source of frequently asked questions and subtle errors. I was intrigued to learn that even the Java Language Specification says, "It is recommended that code not rely crucially on this specification." JLS §15.7 Preferring clear to clever, are there any useful guidelines in this area? Here are a number of resources on the topic: JLS Operators JLS Precedence Java Glossary Princeton Sun Tutorial University of West Florida Usenet discussion Additions or corrections welcome.

    Read the article

  • redefine __and__ operator

    - by wiso
    Why I can't redefine the __and__ operator? class Cut(object): def __init__(self, cut): self.cut = cut def __and__(self, other): return Cut("(" + self.cut + ") && (" + other.cut + ")") a = Cut("a>0") b = cut("b>0") c = a and b print c.cut() I want (a>0) && (b>0), but I got b, that the usual behaviour of and

    Read the article

  • Regex AND operator

    - by user366735
    Based on this answer http://stackoverflow.com/questions/469913/regular-expressions-is-there-an-and-operator I tried the following on http://regexpal.com/ but was unable to get it to work. What am missing? Does javascript not support it? Regex: (?=foo)(?=baz) String: foo,bar,baz

    Read the article

  • subscript operator on pointers

    - by Lodle
    If i have a pointer to an object that has an overloaded subscript operator ( [] ) why cant i do this: MyClass *a = new MyClass(); a[1]; but have to do this instead: MyClass *a = new MyClass(); (*a)[1];

    Read the article

  • Using operator+ without leaking memory?

    - by xokmzxoo
    So the code in question is this: const String String::operator+ (const String& rhs) { String tmp; tmp.Set(this->mString); tmp.Append(rhs.mString); return tmp; } This of course places the String on the stack and it gets removed and returns garbage. And placing it on the heap would leak memory. So how should I do this?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >