Related
Barry In short, is it better to pass pointers by value or const reference? I wrote a simple function to explore: void foo(int* v) { std::cout << *v << endl; }
and void foo(int* const& v) { std::cout << *v << endl; }
I tried looking at the generated assembly,
csguy Isn't passing pointers by const reference for optimization? predecessor. bool testHelper(const TreeNode*& p, const TreeNode*& q) {
return false;
}
TreeNode* test(TreeNode* root, TreeNode* p, TreeNode* q) {
recursiveHelper(p, q);
}
mistake: Line
catch_0x16 When using 3D/2D graphics libraries, I often find myself passing a pointer to the render window to each drawable class that draws itself onto the canvas. However, every time I do this, I worry that by passing a pointer to the render window, the obje
Thomas B. Suppose you have a set of pointers (yes...): std::set<SomeType*> myTypeContainer;
Then suppose you want to search this collection from a const method of SomeType: bool SomeType::IsContainered() const
{
return myTypeContainer.find(this) != myType
Thomas B. Suppose you have a set of pointers (yes...): std::set<SomeType*> myTypeContainer;
Then suppose you want to search this collection from a const method of SomeType: bool SomeType::IsContainered() const
{
return myTypeContainer.find(this) != myType
Thomas B. Suppose you have a set of pointers (yes...): std::set<SomeType*> myTypeContainer;
Then suppose you want to search this collection from a const method of SomeType: bool SomeType::IsContainered() const
{
return myTypeContainer.find(this) != myType
Dean Why does the following work? #include <iostream>
using namespace std;
class PolyLine {
public:
PolyLine() = default;
PolyLine(PolyLine * ptr) {
std::cout << "Ctor called" << std::endl;
}
};
void function(const PolyLine& pt) {
}
int main() {
ACM This was raised recently in code review discussions, but with no satisfactory conclusion. The type in question is similar to the C++ string_view TS. They are simple non-owner wrappers around pointers and lengths, with some custom functions: #include <cstdd
DHW This was raised recently in code review discussions, but with no satisfactory conclusion. The type in question is similar to the C++ string_view TS. They are simple non-owner wrappers around pointers and lengths, with some custom functions: #include <cstdd
ACM This was raised recently in code review discussions, but with no satisfactory conclusion. The type in question is similar to the C++ string_view TS. They are simple non-owner wrappers around pointers and lengths, with some custom functions: #include <cstdd
DHW This was raised recently in code review discussions, but with no satisfactory conclusion. The type in question is similar to the C++ string_view TS. They are simple non-owner wrappers around pointers and lengths, with some custom functions: #include <cstdd
ACM This was raised recently in code review discussions, but with no satisfactory conclusion. The type in question is similar to the C++ string_view TS. They are simple non-owner wrappers around pointers and lengths, with some custom functions: #include <cstdd
MSD561 I don't understand why it crashes. I send a pointer to an array, allocate that array, and then modify the array. what is the problem? #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void f(unsigned char *data) {
data = (unsigned char *)ma
kania 99 I'm trying to create a simple program to better understand how pointers work, but I'm running into a problem. I want to process 3 files main.c modul.c and modul.h. module.h typedef struct
Jon I'm playing with arrays and passing pointers by reference functions. Take the following code as an example: #include<iostream>
void test_fn(const int* const &i){
std::cout<<*i<<std::endl;
}
int main(){
int arr_1[5] {1, 3, 6, 4, 5};
int *int_p
Jon I'm playing with arrays and passing pointers by reference functions. Take the following code as an example: #include<iostream>
void test_fn(const int* const &i){
std::cout<<*i<<std::endl;
}
int main(){
int arr_1[5] {1, 3, 6, 4, 5};
int *int_p
Jon I'm playing with arrays and passing pointers by reference functions. Take the following code as an example: #include<iostream>
void test_fn(const int* const &i){
std::cout<<*i<<std::endl;
}
int main(){
int arr_1[5] {1, 3, 6, 4, 5};
int *int_p
Jon I'm playing with arrays and passing pointers by reference functions. Take the following code as an example: #include<iostream>
void test_fn(const int* const &i){
std::cout<<*i<<std::endl;
}
int main(){
int arr_1[5] {1, 3, 6, 4, 5};
int *int_p
Taoist group I'm learning c++ and recently I read a book that recommends that you use references to const when possible (if the underlying object doesn't change). I have a question, you should pass a reference to a const pointer instead of a const pointer if p
Taoist group I'm learning c++ and recently I read a book that recommends that you use references to const when possible (if the underlying object doesn't change). I have a question, you should pass a reference to a const pointer instead of a const pointer if p
Taoist group I'm learning c++ and recently I read a book that recommends that you use references to const when possible (if the underlying object doesn't change). I have a question, you should pass a reference to a const pointer instead of a const pointer if p
Summer I have a function that looks like this int myclass::setVersion(std::string ver)
{
if (ver.size()>1)
{
version.swap(ver)
return 0;
}
else
return -1;
}
My question is simple, do I verpass it as is or as a pointer to a string? FYI, ve
Summer I have a function that looks like this int myclass::setVersion(std::string ver)
{
if (ver.size()>1)
{
version.swap(ver)
return 0;
}
else
return -1;
}
My question is simple, do I verpass it as is or as a pointer to a string? FYI, ve
Summer I have a function that looks like this int myclass::setVersion(std::string ver)
{
if (ver.size()>1)
{
version.swap(ver)
return 0;
}
else
return -1;
}
My question is simple, do I verpass it as is or as a pointer to a string? FYI, ve
Summer I have a function that looks like this int myclass::setVersion(std::string ver)
{
if (ver.size()>1)
{
version.swap(ver)
return 0;
}
else
return -1;
}
My question is simple, do I verpass it as is or as a pointer to a string? FYI, ve
Balasubramanian v I have a function call like below: Send(0x39,((rLoss>>8)&0xFF),(rLoss&0xFF) );
I want to convert this function to pass by pointer. I wrote two macros BYTE0(var) ((uint8_t *)&var)
BYTE1(var) ((uint8_t)&var)+1)
I want the result to be Send(
Steve Lorimer I have a class template Foowith the following member functions : bool contains(const T& item) const
I have instantiated this with a pointer type: Foo<Bar*>, leading me to expect that the member function will now have the following signature: boo
Neeraj Bansal How to pass pointers const intin recursive calls . I'm calculating Fibonacci recursively using the following code format, but I'm getting an error: error: lvalue must be unary '&' operand** #include <iostream>
void fun(const int *n)
{
fu
Neeraj Bansal How to pass pointers const intin recursive calls . I'm calculating Fibonacci recursively using the following code format, but I'm getting an error: error: lvalue must be unary '&' operand** #include <iostream>
void fun(const int *n)
{
fu