Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
110 views

The following code fails to compile. #include <iostream> #include <map> #include <vector> using namespace std; class mc { string s; public: mc(const std::string s) : s{...
darmual's user avatar
  • 279
0 votes
1 answer
1k views

I am trying to write generic method, which should parse JToken to concrete type, by using implicit conversion operator. I've got my implicit operator like this: public static implicit operator ...
MonTom's user avatar
  • 35
1 vote
2 answers
94 views

int main() { char artist1[4][80] = {}; char artist2[4][80] = {}; char (*pb1)[4][80] = artist1; char (*pb2)[4][80] = artist2; char *arrptr[2] = {pb1, pb2}; } I am trying to ...
A Mirdha's user avatar
0 votes
1 answer
72 views

Why do I get this error from my code? OtaqGetAllRq cannot be used as type parameter ... There is no implicit reference conversion from OtaqGetAllRq to CrudGetAllRequestBase<BaseAxtarishVM> ...
Tim's user avatar
  • 459
1 vote
2 answers
158 views

I am trying to manipulate some 2D array using pointers, I know the basics of pointers but I am having difficulties with this code : { char a[3][10] = { "Malek", "Zied",&...
Malek's user avatar
  • 13
1 vote
1 answer
74 views

I want to use the Scala 3 Implicit Conversion. I have the following construct that I want to migrate: implicit def toTesterObjectScenario[In <: Product]( ...
pme's user avatar
  • 14.9k
-1 votes
3 answers
942 views

What if I want to print a bool var value, but I used %f and %s in the printf format string? How does the code work? bool a = true; bool b = "true"; bool c = '\0'; bool d = "\0"; ...
varun sethi's user avatar
1 vote
1 answer
49 views

for some odd reason when I run this code: int func(int arr[],int n) { int a = *(&arr + 1) - arr; printf("%d",a); } I get an address, and when I run the same code inside main I ...
Rani Giro's user avatar
4 votes
1 answer
232 views

Consider the following class that implements a user-conversion to std::string and const char*: class String { public: String(std::string_view s) : str{s} {} operator std::string() const { ...
joergbrech's user avatar
  • 2,812
-1 votes
2 answers
99 views

I have an array of size MAX of class pointers. How can I define a pointer to the same, and access member functions of base, derived, etc? class base { public : base() {cout << "base ...
KuSa's user avatar
  • 9
0 votes
2 answers
66 views

when i tried to understand more about how array name is treated as pointer, I wrote this code : #include<stdio.h> int main() { int a[] = {1, 2, 3, 4, 5, 6}; printf("%d \n",*...
Mahmoud Hamed's user avatar
0 votes
1 answer
268 views

I have a scenario where I would like to call sum on a sequence of (Double, Double) tuples. Ideally I would like to do something like the following: implicit def toTupleNumeric[T](num: Numeric[T]) = ...
user79074's user avatar
  • 5,412
1 vote
1 answer
303 views

I have a class like this: class Foo { private: std::string m_data; public: Foo() = default; explicit Foo(double value); explicit Foo(float value); ...
HeapOverflow's user avatar
4 votes
0 answers
193 views

As the title says, I'd like to prevent implicit conversions from a derived class to its base class while retaining public inheritance. I do not have access to the base class implementation. Example: //...
Vittorio Romeo's user avatar
7 votes
4 answers
1k views

I'm trying to bind some ta-lib functions and then callback. Here is the simplified sample code: #include <functional> #include <type_traits> #include <cstdint> struct DataChunk { ...
Mark Taylor's user avatar
1 vote
1 answer
112 views

This might be a dumb question but I'm just learning C. I have declared: #include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct STRUCTURE{ char name[30]; }...
rainer's user avatar
  • 37
1 vote
2 answers
414 views

Why am I getting : (373)implicit signed to unsigned conversion by doing: fan_on_hh = hh + fan_hh_increment All fan_on_hh, hh and fan_hh_increment are unsigned char. This post suggests to do this: ...
Andras's user avatar
  • 403
0 votes
1 answer
846 views

in snowflake i have numeric column with values like 202201, 202305,202248 that refers to year week combination. How can i convert it into first or last day of tha week? for example 202251 will be '...
szczawek's user avatar
5 votes
1 answer
95 views

The following small C++ program involving a call to the template function std::atomic_fetch_add() fails to compile in godbolt for x86-64 clang versions less than 9.0 and gcc versions less than 9.1, in ...
zeelor's user avatar
  • 53
1 vote
1 answer
194 views

I was practicing with void pointers when this code successfully compiled: #include <stdio.h> int main() { void *x = (void*) 576; int *y = x; printf("%d\n", y); return ...
user21066444's user avatar
0 votes
2 answers
82 views

Here, i attached code image how it treat in char array? If image is not clear, then refere this code #include <stdio.h> int main() { char c[3] = {'s', 'a', 'h'}; int a[3] = {1, 2, 3}; ...
Sahil Nayak's user avatar
0 votes
2 answers
115 views

I am starting to develop in Scala, so I started witha really simple RESTful API using AKKA HTTP actors and then wanted to add a PostgreSQL database to "close up" the project. The thing is ...
Drethtar's user avatar
0 votes
0 answers
139 views

I have a class where I used implicit operator to initialize the class when string value assigned like this MyClass db = ""; My class is public class MyClass { public static implicit ...
Neeraj Kumar Gupta's user avatar
2 votes
0 answers
204 views

EDIT 2 - BEGIN: What I have not verified, and I should have, was if the conversion of my example works for regular types. And it doesn’t neither. So, the title and all my post is surely wrong. Sorry ...
Readren's user avatar
  • 1,290
0 votes
0 answers
70 views

As practice I tried to make a wrapper around raw pointers to have cleaner memory management when using CUDA. Basically I made a PointerBase template that has a PointerBase specialization for const ...
pnarvor's user avatar
  • 170
0 votes
0 answers
74 views

I'm working with a function that takes a list of email address records and returns the appropriate one for the use case. This list is passed to the function as an List[Map[String, String]], and the ...
James Kelleher's user avatar
0 votes
3 answers
169 views

#include <stdio.h> int main(void) { int x = 5; int y = &x; printf("Signed Value of Y: %d \n", y); printf("Unsigned Value of Y: %u", y); return 0; } ...
Tushar K. Sengar's user avatar
1 vote
1 answer
130 views

As I am working on a topic related to MISRA, I had some doubts about this line of code: int *a = (int *) malloc( 12 ); as rule 11.5 [A] "A conversion should not be performed from pointer to void ...
Zimo93's user avatar
  • 31
1 vote
1 answer
57 views

The implicit cast: FooType Foo = (FooType)someParameter; The Explicit cast: FooType Foo = someParameter as FooType; However, Does double wrapping an implicit cast make it an explicit cast if ...
GroupBool's user avatar
5 votes
1 answer
232 views

In C++, I'm searching for the crucial sections of the standard explaining the subtle difference in behavior I've observed between the language's two pointer-to-member access operators, .* and ->*. ...
ngmr80's user avatar
  • 145
3 votes
3 answers
156 views

I would like to introduce a custom class, say Decimal2, so that I would be able to round through type ascription: val x: Decimal2 = 1.2345 // 1.24 So far I've tried this: class Decimal2(val value: ...
Sergey Bushmanov's user avatar
2 votes
1 answer
89 views

I have this exam question that says : Bar can be properly constructed with ... and I have to choose the correct option(s): class Bar{ public: Bar(std::string); Bar(int a=10,double b=7.10, ...
Xavi's user avatar
  • 67
0 votes
1 answer
121 views

Regarding vector<double> v2 = 9; //error: no conversion from int to vector Is there no implicit conversion sequence of the copy-initialization from int to vector<double> because std::...
CosmicHusky's user avatar
0 votes
1 answer
155 views

I am having difficulty reading values from the following object type array returned from Oracle stored procedure var arrUtil = cmd.Parameters["UTILBYDAY"].Value; The arrUtil array is of the ...
user20774180's user avatar
3 votes
0 answers
41 views

I'm diving into the implicit conversions of C++20, and came up with this example: #include <iostream> void f(int a){ std::cout << 1; } void f(int &a){ std::cout << 2; } int ...
ineiti's user avatar
  • 444
0 votes
1 answer
246 views

the 6.3.1.8 section of the C standard says the next: . . . Many operators that expect operands of arithmetic type cause conversions and yield result types in a similar way. The purpose is to ...
Cblue X's user avatar
  • 353
0 votes
0 answers
59 views

i fund a post here in SO, that states some rules for implicit type conversion: — If both operands have the same type, no further conversion is needed. — Otherwise, if both operands have signed ...
Cblue X's user avatar
  • 353
0 votes
1 answer
76 views

The following conversion works because of int2double implicit conversion scala> val d: Double = 2 d: Double = 2.0 prior to 2.10, this implicit conversion was part of Predef object and was thus ...
Rupam Bhattacharjee's user avatar
1 vote
1 answer
72 views

For example, for the following code, I know that p is a pointer, which points to the first element of the array arr, and I also know that the array will degenerate into an array under certain ...
Kargath's user avatar
  • 539
0 votes
1 answer
72 views

I am having trouble declaring pointer to 2d variable of chars... const char * d1 [][2] = { { "murderer", "termination specialist" }, { "failure", "non-...
Matouš Kovář's user avatar
1 vote
3 answers
76 views

I'm a university student. and the teacher wants me to pass multiple strings to function. The answer output is correct but I wonder what the warning is why it shows and how to fix it in my case. I try ...
LunaticCoder's user avatar
1 vote
1 answer
1k views

QColor can return rgba values of type int (32-bit signed integer). Why is that? The color values range from 0-255, don't they? Is there any situation where this might not be the case? I'm considering ...
anjelomerte's user avatar
1 vote
2 answers
210 views

In addition to pointers, C++ also provides references that behave similarly. In addition to these built-in types, it also gives the option to construct custom types that mimic this behavior. Take ...
Post Self's user avatar
  • 1,582
8 votes
1 answer
292 views

Assume we have procedure void f(X2);. Further assume we have types X1 and X2 that do not share an inheritance hierarchy. We want to call it like this: f(X1{}) and have X1 implicitly convert into X2. ...
Post Self's user avatar
  • 1,582
1 vote
1 answer
607 views

I want to print the data of array by using pointers so I try to save the address of array in the pointer. But the pointer doesn't print the data. I will print a second array as well later on so there ...
L127Bangtanned's user avatar
0 votes
1 answer
46 views

I tried making code to simulate boss fights. Firstly initialize the array of struct, making pointer out of it, and passing it into function. #include <stdio.h> struct machine_gun{ char name[...
MJee's user avatar
  • 11
0 votes
3 answers
81 views

I want to take user input for a 2D array using pointer name Let's say I have a 2D array named arr1[3][3] and the pointer variable name is ptr1. Is it possible use scanf with the pointer variable name?...
Asif Mahbub's user avatar
0 votes
2 answers
79 views

What is the difference between int(*a)[5]; int b[5] = { 1, 2, 3, 4, 5 }; i = 0; a = &b; for (i = 0; i < 5; i++) printf("%d\n", *(*a+i)); and int b[5] = { 1, 2, 3, 4, 5 }; int *y ...
user2889669's user avatar
0 votes
1 answer
245 views

One of the features of C++20 is Converting from T* to bool should be considered narrowing but perhaps I am not familiar with the history of this and trying to wrap my head around it in terms of what's ...
xyf's user avatar
  • 713
-1 votes
1 answer
145 views

I encountered a question in competitive programming and the solution for that include a for loop with a syntax like for(int i = 0; i < m and n; i++){ //Do Something } When I changed the ...
Kushagra Gupta's user avatar

1 2 3
4
5
50