|
by: tornado |
last post by:
hi all,
i am pretty new to c++. i have this problem for which i am unable to
think a solution. i don't understand how to pass a vector refernce
back to the callin function. And how this reference will be handled by
the calling function ? Can any one in the group point me to the
correct solution for it ? Any code snippets will be of great help.
Thanks in advance.
|
by: mjm |
last post by:
Folks,
Stroustrup indicates that returning by value can be faster than
returning by reference but gives no details as to the size of the
returned object up to which this holds.
My question is up to which size m would you expect
vector<double> returns_by_value()
{
|
by: cppaddict |
last post by:
Hi,
Is it considered bad form to have the subscript operator return a
const reference variable? If not, what is the proper way to do it?
My question was prompted by the code below, my problematic attempt to
implement a subscript operator that returns a const reference. The
dubious code is marked at the end.
<code>
|
by: Alfonso Morra |
last post by:
Hi,
What is the recomended way of returning an STL container (e.g.
std::string, std::vector etc fom a function?
Is it by simply returning a local variable? (I doubt it)
std::string foo(const std::string& rhs) {
std::string var = rhs ;
var += " received" ;
|
by: Fraser Ross |
last post by:
I need to know the syntax for writing a reference of an array. I haven't
seen it done often. I have a class with a member array and I want a member
function to return an reference to it. Returning a pointer to the first
element might do but I want to do what I've said.
Fraser.
|
|
by: Gernot Frisch |
last post by:
Which method is the fastest/best:
std::vector<intfoo1()
{
std::vector<intv;
...
reutun v;
}
std::vector<int>& foo2()
|
by: josh |
last post by:
Hi, I'm converting (for learning purpose) )a program from Java to C++
and I've a doubt:
In Java every argument (variable and reference types) is passed and
returned in functions by-value so if I want to create inside that
function a matrix (i.e. int a) and than passing the reference to it
I can simply
returning that value:
in main()
|
by: arnuld |
last post by:
/* C++ Primer - 4/e
*
* 1st example from section 7.2.2, page 234
* returning 2 values from a function
*
* STATEMENT:
* to find a specific value in a vector and number of times
* that value occurs in th vector.
*/
|
by: pauldepstein |
last post by:
Below is posted from a link for Stanford students in computer
science.
QUOTE BEGINS HERE
Because of the risk of misuse, some experts recommend never returning
a
reference from a function or method.
QUOTE ENDS HERE
I have never heard anyone else say that it is a problem for a function
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|