Search Results

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

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

  • What is operator<< <> in C++?

    - by Austin Hyde
    I have seen this in a few places, and to confirm I wasn't crazy, I looked for other examples. Apparently this can come in other flavors as well, eg operator+ <>. However, nothing I have seen anywhere mentions what it is, so I thought I'd ask. It's not the easiest thing to google operator<< <>( :-)

    Read the article

  • Why can operator-> be overloaded manually?

    - by FredOverflow
    Wouldn't it make sense if p->m was just syntactic sugar for (*p).m? Essentially, every operator-> that I have ever written could have been implemented as follows: Foo::Foo* operator->() { return &**this; } Is there any case where I would want p->m to mean something else than (*p).m?

    Read the article

  • cast operator to base class within a thin wrapper derived class

    - by miked
    I have a derived class that's a very thin wrapper around a base class. Basically, I have a class that has two ways that it can be compared depending on how you interpret it so I created a new class that derives from the base class and only has new constructors (that just delegate to the base class) and a new operator==. What I'd like to do is overload the operator Base&() in the Derived class so in cases where I need to interpret it as the Base. For example: class Base { Base(stuff); Base(const Base& that); bool operator==(Base& rhs); //typical equality test }; class Derived : public Base { Derived(stuff) : Base(stuff) {}; Derived(const Base& that) : Base(that) {}; Derived(const Derived& that) : Base(that) {}; bool operator==(Derived& rhs); //special case equality test operator Base&() { return (Base&)*this; //Is this OK? It seems wrong to me. } }; If you want a simple example of what I'm trying to do, pretend I had a String class and String==String is the typical character by character comparison. But I created a new class CaseInsensitiveString that did a case insensitive compare on CaseInsensitiveString==CaseInsensitiveString but in all other cases just behaved like a String. it doesn't even have any new data members, just an overloaded operator==. (Please, don't tell me to use std::string, this is just an example!) Am I going about this right? Something seems fishy, but I can't put my finger on it.

    Read the article

  • How to overload operator<< for qDebug

    - by iyo
    Hi, I'm trying to create more useful debug messages for my class where store data. My code is looking something like this #include <QAbstractTableModel> #include <QDebug> /** * Model for storing data. */ class DataModel : public QAbstractTableModel { // for debugging purposes friend QDebug & operator<< (const QDebug &d, DataModel model); //other stuff }; /** * Overloading operator for debugging purposes */ QDebug & operator<< (QDebug &d, DataModel model) { d << "Hello world!"; return d; } I expect qDebug() << model will print "Hello world!". However, there is alway something like "QAbstractTableModel(0x1c7e520)" on the output. Do you have any idea what's wrong?

    Read the article

  • How operator oveloading works

    - by Rasmi Ranjan Nayak
    I have below code class rectangle { ..... .....//Some code int operator+(rectangle r1) { return(r1.length+length); } }; In main fun. int main() { rectangle r1(10,20); rectangle r2(40,60); rectangle r3(30,60); int len = r1+r3; } Here if we will see in operator+(), we are doing r1.length + length. How the compiler comes to know that the 2nd length in return statement belong to object r3 not to r1 or r2? I think answer may be in main() we have writeen int len = r1+r3; If that is the case then why do we need to write in operator+(....) { r1.lenth + lenth; //Why not length + length? } Why not length + length? Bcause compiler already knows from main() that the first length belong to object r1 and 2nd to object r3.

    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

  • Hello Operator, My Switch Is Bored

    - by Paul White
    This is a post for T-SQL Tuesday #43 hosted by my good friend Rob Farley. The topic this month is Plan Operators. I haven’t taken part in T-SQL Tuesday before, but I do like to write about execution plans, so this seemed like a good time to start. This post is in two parts. The first part is primarily an excuse to use a pretty bad play on words in the title of this blog post (if you’re too young to know what a telephone operator or a switchboard is, I hate you). The second part of the post looks at an invisible query plan operator (so to speak). 1. My Switch Is Bored Allow me to present the rare and interesting execution plan operator, Switch: Books Online has this to say about Switch: Following that description, I had a go at producing a Fast Forward Cursor plan that used the TOP operator, but had no luck. That may be due to my lack of skill with cursors, I’m not too sure. The only application of Switch in SQL Server 2012 that I am familiar with requires a local partitioned view: CREATE TABLE dbo.T1 (c1 int NOT NULL CHECK (c1 BETWEEN 00 AND 24)); CREATE TABLE dbo.T2 (c1 int NOT NULL CHECK (c1 BETWEEN 25 AND 49)); CREATE TABLE dbo.T3 (c1 int NOT NULL CHECK (c1 BETWEEN 50 AND 74)); CREATE TABLE dbo.T4 (c1 int NOT NULL CHECK (c1 BETWEEN 75 AND 99)); GO CREATE VIEW V1 AS SELECT c1 FROM dbo.T1 UNION ALL SELECT c1 FROM dbo.T2 UNION ALL SELECT c1 FROM dbo.T3 UNION ALL SELECT c1 FROM dbo.T4; Not only that, but it needs an updatable local partitioned view. We’ll need some primary keys to meet that requirement: ALTER TABLE dbo.T1 ADD CONSTRAINT PK_T1 PRIMARY KEY (c1);   ALTER TABLE dbo.T2 ADD CONSTRAINT PK_T2 PRIMARY KEY (c1);   ALTER TABLE dbo.T3 ADD CONSTRAINT PK_T3 PRIMARY KEY (c1);   ALTER TABLE dbo.T4 ADD CONSTRAINT PK_T4 PRIMARY KEY (c1); We also need an INSERT statement that references the view. Even more specifically, to see a Switch operator, we need to perform a single-row insert (multi-row inserts use a different plan shape): INSERT dbo.V1 (c1) VALUES (1); And now…the execution plan: The Constant Scan manufactures a single row with no columns. The Compute Scalar works out which partition of the view the new value should go in. The Assert checks that the computed partition number is not null (if it is, an error is returned). The Nested Loops Join executes exactly once, with the partition id as an outer reference (correlated parameter). The Switch operator checks the value of the parameter and executes the corresponding input only. If the partition id is 0, the uppermost Clustered Index Insert is executed, adding a row to table T1. If the partition id is 1, the next lower Clustered Index Insert is executed, adding a row to table T2…and so on. In case you were wondering, here’s a query and execution plan for a multi-row insert to the view: INSERT dbo.V1 (c1) VALUES (1), (2); Yuck! An Eager Table Spool and four Filters! I prefer the Switch plan. My guess is that almost all the old strategies that used a Switch operator have been replaced over time, using things like a regular Concatenation Union All combined with Start-Up Filters on its inputs. Other new (relative to the Switch operator) features like table partitioning have specific execution plan support that doesn’t need the Switch operator either. This feels like a bit of a shame, but perhaps it is just nostalgia on my part, it’s hard to know. Please do let me know if you encounter a query that can still use the Switch operator in 2012 – it must be very bored if this is the only possible modern usage! 2. Invisible Plan Operators The second part of this post uses an example based on a question Dave Ballantyne asked using the SQL Sentry Plan Explorer plan upload facility. If you haven’t tried that yet, make sure you’re on the latest version of the (free) Plan Explorer software, and then click the Post to SQLPerformance.com button. That will create a site question with the query plan attached (which can be anonymized if the plan contains sensitive information). Aaron Bertrand and I keep a close eye on questions there, so if you have ever wanted to ask a query plan question of either of us, that’s a good way to do it. The problem The issue I want to talk about revolves around a query issued against a calendar table. The script below creates a simplified version and adds 100 years of per-day information to it: USE tempdb; GO CREATE TABLE dbo.Calendar ( dt date NOT NULL, isWeekday bit NOT NULL, theYear smallint NOT NULL,   CONSTRAINT PK__dbo_Calendar_dt PRIMARY KEY CLUSTERED (dt) ); GO -- Monday is the first day of the week for me SET DATEFIRST 1;   -- Add 100 years of data INSERT dbo.Calendar WITH (TABLOCKX) (dt, isWeekday, theYear) SELECT CA.dt, isWeekday = CASE WHEN DATEPART(WEEKDAY, CA.dt) IN (6, 7) THEN 0 ELSE 1 END, theYear = YEAR(CA.dt) FROM Sandpit.dbo.Numbers AS N CROSS APPLY ( VALUES (DATEADD(DAY, N.n - 1, CONVERT(date, '01 Jan 2000', 113))) ) AS CA (dt) WHERE N.n BETWEEN 1 AND 36525; The following query counts the number of weekend days in 2013: SELECT Days = COUNT_BIG(*) FROM dbo.Calendar AS C WHERE theYear = 2013 AND isWeekday = 0; It returns the correct result (104) using the following execution plan: The query optimizer has managed to estimate the number of rows returned from the table exactly, based purely on the default statistics created separately on the two columns referenced in the query’s WHERE clause. (Well, almost exactly, the unrounded estimate is 104.289 rows.) There is already an invisible operator in this query plan – a Filter operator used to apply the WHERE clause predicates. We can see it by re-running the query with the enormously useful (but undocumented) trace flag 9130 enabled: Now we can see the full picture. The whole table is scanned, returning all 36,525 rows, before the Filter narrows that down to just the 104 we want. Without the trace flag, the Filter is incorporated in the Clustered Index Scan as a residual predicate. It is a little bit more efficient than using a separate operator, but residual predicates are still something you will want to avoid where possible. The estimates are still spot on though: Anyway, looking to improve the performance of this query, Dave added the following filtered index to the Calendar table: CREATE NONCLUSTERED INDEX Weekends ON dbo.Calendar(theYear) WHERE isWeekday = 0; The original query now produces a much more efficient plan: Unfortunately, the estimated number of rows produced by the seek is now wrong (365 instead of 104): What’s going on? The estimate was spot on before we added the index! Explanation You might want to grab a coffee for this bit. Using another trace flag or two (8606 and 8612) we can see that the cardinality estimates were exactly right initially: The highlighted information shows the initial cardinality estimates for the base table (36,525 rows), the result of applying the two relational selects in our WHERE clause (104 rows), and after performing the COUNT_BIG(*) group by aggregate (1 row). All of these are correct, but that was before cost-based optimization got involved :) Cost-based optimization When cost-based optimization starts up, the logical tree above is copied into a structure (the ‘memo’) that has one group per logical operation (roughly speaking). The logical read of the base table (LogOp_Get) ends up in group 7; the two predicates (LogOp_Select) end up in group 8 (with the details of the selections in subgroups 0-6). These two groups still have the correct cardinalities as trace flag 8608 output (initial memo contents) shows: During cost-based optimization, a rule called SelToIdxStrategy runs on group 8. It’s job is to match logical selections to indexable expressions (SARGs). It successfully matches the selections (theYear = 2013, is Weekday = 0) to the filtered index, and writes a new alternative into the memo structure. The new alternative is entered into group 8 as option 1 (option 0 was the original LogOp_Select): The new alternative is to do nothing (PhyOp_NOP = no operation), but to instead follow the new logical instructions listed below the NOP. The LogOp_GetIdx (full read of an index) goes into group 21, and the LogOp_SelectIdx (selection on an index) is placed in group 22, operating on the result of group 21. The definition of the comparison ‘the Year = 2013’ (ScaOp_Comp downwards) was already present in the memo starting at group 2, so no new memo groups are created for that. New Cardinality Estimates The new memo groups require two new cardinality estimates to be derived. First, LogOp_Idx (full read of the index) gets a predicted cardinality of 10,436. This number comes from the filtered index statistics: DBCC SHOW_STATISTICS (Calendar, Weekends) WITH STAT_HEADER; The second new cardinality derivation is for the LogOp_SelectIdx applying the predicate (theYear = 2013). To get a number for this, the cardinality estimator uses statistics for the column ‘theYear’, producing an estimate of 365 rows (there are 365 days in 2013!): DBCC SHOW_STATISTICS (Calendar, theYear) WITH HISTOGRAM; This is where the mistake happens. Cardinality estimation should have used the filtered index statistics here, to get an estimate of 104 rows: DBCC SHOW_STATISTICS (Calendar, Weekends) WITH HISTOGRAM; Unfortunately, the logic has lost sight of the link between the read of the filtered index (LogOp_GetIdx) in group 22, and the selection on that index (LogOp_SelectIdx) that it is deriving a cardinality estimate for, in group 21. The correct cardinality estimate (104 rows) is still present in the memo, attached to group 8, but that group now has a PhyOp_NOP implementation. Skipping over the rest of cost-based optimization (in a belated attempt at brevity) we can see the optimizer’s final output using trace flag 8607: This output shows the (incorrect, but understandable) 365 row estimate for the index range operation, and the correct 104 estimate still attached to its PhyOp_NOP. This tree still has to go through a few post-optimizer rewrites and ‘copy out’ from the memo structure into a tree suitable for the execution engine. One step in this process removes PhyOp_NOP, discarding its 104-row cardinality estimate as it does so. To finish this section on a more positive note, consider what happens if we add an OVER clause to the query aggregate. This isn’t intended to be a ‘fix’ of any sort, I just want to show you that the 104 estimate can survive and be used if later cardinality estimation needs it: SELECT Days = COUNT_BIG(*) OVER () FROM dbo.Calendar AS C WHERE theYear = 2013 AND isWeekday = 0; The estimated execution plan is: Note the 365 estimate at the Index Seek, but the 104 lives again at the Segment! We can imagine the lost predicate ‘isWeekday = 0’ as sitting between the seek and the segment in an invisible Filter operator that drops the estimate from 365 to 104. Even though the NOP group is removed after optimization (so we don’t see it in the execution plan) bear in mind that all cost-based choices were made with the 104-row memo group present, so although things look a bit odd, it shouldn’t affect the optimizer’s plan selection. I should also mention that we can work around the estimation issue by including the index’s filtering columns in the index key: CREATE NONCLUSTERED INDEX Weekends ON dbo.Calendar(theYear, isWeekday) WHERE isWeekday = 0 WITH (DROP_EXISTING = ON); There are some downsides to doing this, including that changes to the isWeekday column may now require Halloween Protection, but that is unlikely to be a big problem for a static calendar table ;)  With the updated index in place, the original query produces an execution plan with the correct cardinality estimation showing at the Index Seek: That’s all for today, remember to let me know about any Switch plans you come across on a modern instance of SQL Server! Finally, here are some other posts of mine that cover other plan operators: Segment and Sequence Project Common Subexpression Spools Why Plan Operators Run Backwards Row Goals and the Top Operator Hash Match Flow Distinct Top N Sort Index Spools and Page Splits Singleton and Range Seeks Bitmaps Hash Join Performance Compute Scalar © 2013 Paul White – All Rights Reserved Twitter: @SQL_Kiwi

    Read the article

  • Class Assignment Operators

    - by Maxpm
    I made the following operator overloading test: #include <iostream> #include <string> using namespace std; class TestClass { string ClassName; public: TestClass(string Name) { ClassName = Name; cout << ClassName << " constructed." << endl; } ~TestClass() { cout << ClassName << " destructed." << endl; } void operator=(TestClass Other) { cout << ClassName << " in operator=" << endl; cout << "The address of the other class is " << &Other << "." << endl; } }; int main() { TestClass FirstInstance("FirstInstance"); TestClass SecondInstance("SecondInstance"); FirstInstance = SecondInstance; SecondInstance = FirstInstance; return 0; } The assignment operator behaves as-expected, outputting the address of the other class. Now, how would I actually assign something from the other class? For example, something like this: void operator=(TestClass Other) { ClassName = Other.ClassName; }

    Read the article

  • Java operator overload

    - by rengolin
    Coming from C++ to Java, the obvious unanswered question is why not operator overload. On the web some go about: "it's clearly obfuscated and complicate maintenance" but no one really elaborates that further (I completely disagree, actually). Other people pointed out that some objects do have an overload (like String operator +) but that is not extended to other objects nor is extensible to the programmer's decision. I've heard that they're considering extending the favour to BigInt and similar, but why not open that for our decisions? How exactly if complicates maintenance and where on earth does this obfuscate code? Isn't : Complex a, b, c; a = b + c; much simpler than: Complex a, b, c; a.equals( b.add(c) ); ??? Or is it just habit?

    Read the article

  • Function template overloading: link error

    - by matt
    I'm trying to overload a "display" method as follows: template <typename T> void imShow(T* img, int ImgW, int ImgH); template <typename T1, typename T2> void imShow(T1* img1, T2* img2, int ImgW, int ImgH); I am then calling the template with unsigned char* im1 and char* im2: imShow(im1, im2, ImgW, ImgH); This compiles fine, but i get a link error "unresolved external symbol" for: imShow<unsigned char,char>(unsigned char *,char *,int,int) I don't understand what I did wrong!

    Read the article

  • PHP Overloading, singleton instance

    - by jamalali81
    I've sort of created my own MVC framework and am curious as to how other frameworks can send properties from the "controller" to the "view". Zend does something along the lines of $this->view->name = 'value'; My code is: file: services_hosting.php class services_hosting extends controller { function __construct($sMvcName) { parent::__construct($sMvcName); $this->setViewSettings(); } public function setViewSettings() { $p = new property; $p->banner = '/path/to/banners/home.jpg'; } } file: controller.php class controller { public $sMvcName = "home"; function __construct($sMvcName) { if ($sMvcName) { $this->sMvcName = $sMvcName; } include('path/to/views/view.phtml'); } public function renderContent() { include('path/to/views/'.$this->sMvcName.'.phtml'); } } file: property.php class property { private $data = array(); protected static $_instance = null; public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } public function __set($name, $value) { $this->data[$name] = $value; } public function __get($name) { if (array_key_exists($name, $this->data)) { return $this->data[$name]; } } public function __isset($name) { return isset($this->data[$name]); } public function __unset($name) { unset($this->data[$name]); } } In my services_hosting.phtml "view" file I have: <img src="<?php echo $this->p->banner ?>" /> This just does not work. Am I doing something fundamentally wrong or is my logic incorrect? I seem to be going round in circles at the moment. Any help would be very much appreciated.

    Read the article

  • Function overloading in C

    - by Andrei Ciobanu
    Today, looking at the man page for open(), I've noticed this function is 'overloaded': int open(const char *pathname, int flags); int open(const char *pathname, int flags, mode_t mode); I didn't thought it's possible on C. What's the 'trick' for achieving this ?

    Read the article

  • C++ function overloading and dynamic binding compile problem

    - by Olorin
    #include <iostream> using namespace std; class A { public: virtual void foo(void) const { cout << "A::foo(void)" << endl; } virtual void foo(int i) const { cout << i << endl; } virtual ~A() {} }; class B : public A { public: void foo(int i) const { this->foo(); cout << i << endl; } }; class C : public B { public: void foo(void) const { cout << "C::foo(void)" << endl; } }; int main(int argc, char ** argv) { C test; test.foo(45); return 0; } The above code does not compile with: $>g++ test.cpp -o test.exe test.cpp: In member function 'virtual void B::foo(int) const': test.cpp:17: error: no matching function for call to 'B::foo() const' test.cpp:17: note: candidates are: virtual void B::foo(int) const test.cpp: In function 'int main(int, char**)': test.cpp:31: error: no matching function for call to 'C::foo(int)' test.cpp:23: note: candidates are: virtual void C::foo() const It compiles if method "foo(void)" is changed to "goo(void)". Why is this so? Is it possible to compile the code without changing the method name of "foo(void)"? Thanks.

    Read the article

  • Does C# allow method overloading, PHP style (__call)?

    - by mr.b
    In PHP, there is a special method named __call($calledMethodName, $arguments), which allows class to catch calls to non-existing methods, and do something about it. Since most of classic languages are strongly typed, compiler won't allow calling a method that does not exist, I'm clear with that part. What I want to accomplish (and I figured this is how I would do it in PHP, but C# is something else) is to proxy calls to a class methods and log each of these calls. Right now, I have code similar to this: class ProxyClass { static logger; public AnotherClass inner { get; private set; } public ProxyClass() { inner = new AnotherClass(); } } class AnotherClass { public void A() {} public void B() {} public void C() {} // ... } // meanwhile, in happyCodeLandia... ProxyClass pc = new ProxyClass(); pc.inner.A(); pc.inner.B(); // ... So, how can I proxy calls to an object instance in extensible way? Extensible, meaning that I don't have to modify ProxyClass whenever AnotherClass changes. In my case, AnotherClass can have any number of methods, so it wouldn't be appropriate to overload or wrap all methods to add logging. I am aware that this might not be the best approach for this kind of problem, so if anyone has idea what approach to use, shoot. Thanks!

    Read the article

  • c++ function overloading, making fwrite/fread act like PHP versions

    - by Newbie
    I'm used to the PHP fwrite/fread parameter orders, and i want to make them the same in C++ too. I want it to work with char and string types, and also any data type i put in it (only if length is defined). I am total noob on c++, this is what i made so far: size_t fwrite(FILE *fp, const std::string buf, const size_t len = SIZE_MAX){ if(len == SIZE_MAX){ return fwrite(buf.c_str(), 1, buf.length(), fp); }else{ return fwrite(buf.c_str(), 1, len, fp); } } size_t fwrite(FILE *fp, const void *buf, const size_t len = SIZE_MAX){ if(len == SIZE_MAX){ return fwrite((const char *)buf, 1, strlen((const char *)buf), fp); }else{ return fwrite(buf, 1, len, fp); } } Should this work just fine? And how should this be done if i wanted to do it the absolutely best possible way?

    Read the article

  • Haskell: Problems with overloading: Interpreter can´t tell which + to use

    - by Ben
    Hi, I want to make functions Double - Double an instance of the Num typeclass. I want to define the sum of two functions as sum of their images. So I wrote instance Num Function where f + g = (\ x - (f x) + (g x)) Here the compiler complains he can´t tell whether I´m using Prelude.+ or Module.+ in the lambda expression. So I imported Prelude qualified as P and wrote instance Num Function where f + g = (\ x - (f x) P.+ (g x)) This compiles just fine, but when I try to add two functions in GHCi the interpreter complains again he can´t tell whether I´m using Prelude.+ or Module.+. Is there any way I can solve this problem?

    Read the article

  • C++ template overloading - wrong function called

    - by DeadMG
    template<typename T> T* Push(T* ptr); template<typename T> T* Push(T& ref); template<typename T, typename T1> T* Push(T1&& ref); I have int i = 0; Push<int>(i); But the compiler calls it ambiguous. How is that ambiguous? The second function is clearly the preferred match since it's more specialized. Especially since the T1&& won't bind to an lvalue unless I explicitly forward/move it. Sorry - i is an int. Otherwise, the question would make no sense, and I thought people would infer it since it's normally the loop iterator.

    Read the article

  • Strange overloading rules in C++

    - by bucels
    I'm trying to compile this code with GCC 4.5.0: #include <algorithm> #include <vector> template <typename T> void sort(T, T) {} int main() { std::vector<int> v; sort(v.begin(), v.end()); } But it doesn't seem to work: $ g++ -c nm.cpp nm.cpp: In function ‘int main()’: nm.cpp:9:28: error: call of overloaded ‘sort(std::vector<int>::iterator, std::vector<int>::iterator)’ is ambiguous nm.cpp:4:28: note: candidates are: void sort(T, T) [with T = __gnu_cxx::__normal_iterator<int*, std::vector<int> >] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/stl_algo.h:5199:69: note: void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >] Comeau compiles this code without errors. (4.3.10.1 Beta2, strict C++03, no C++0x) Is this valid C++?

    Read the article

  • Overloading methods in C#

    - by Craig Johnston
    Is there a way to simplify the process of adding an overloaded method in C# using VS2005? In VB6, I would have just added an Optional parameter the function, but in C# do I have to have to type out a whole new method with this new parameter?

    Read the article

  • Why this function overloading is not working?

    - by Jack
    class CConfFile { public: CConfFile(const std::string &FileName); ~CConfFile(); ... std::string GetString(const std::string &Section, const std::string &Key); void GetString(const std::string &Section, const std::string &Key, char *Buffer, unsigned int BufferSize); ... } string CConfFile::GetString(const string &Section, const string &Key) { return GetKeyValue(Section, Key); } void GetString(const string &Section, const string &Key, char *Buffer, unsigned int BufferSize) { string Str = GetString(Section, Key); // *** ERROR *** strncpy(Buffer, Str.c_str(), Str.size()); } Why do I get an error too few arguments to function ‘void GetString(const std::string&, const std::string&, char*, unsigned int)' at the second function ? Thanks

    Read the article

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