Paulo
What I know is a function signature is its name and parameters types. And it's what is important for overload, and it not consider the return type. A declaration is everthing considering the return type, and is something I don't have here
Paulo
It's a non-correct function call The correct one would be fun(Complex{})
Look at the function call that you mentioned, we have a type declared, this is what I think it's a signature
Danya🔥
Look at the function call that you mentioned, we have a type declared, this is what I think it's a signature
Please read carefully the original message > and he calls it like > fun(Complex calculator{}) It is a function call that has been written with a mistake, not something else
Paulo
She*
Ok, sorry. She.b
Anonymous
It's a non-correct function call The correct one would be fun(Complex{})
Actually I used the same type that OP used: "ComplexCalculator" but auto correct changed it to "Complex calculator"
Naol D
Greeting everyone! I have a question related to macro in c++. As an example in a header file I defiened a macro named TABLE type of std::map<string, int> with some initial values. So when using this macro in other part of my program could that be a bottleneck for performance and space? I had the idea becuase a macro is replaced by the preprocessor.
Naol D
Do NOT use macros to create type aliases Use type aliases https://en.cppreference.com/w/cpp/language/type_alias
I wanted the map to be constant and accessible thats why I did that! let me send you a sample
Danya🔥
It does not make any sense
Danya🔥
And your assumption, to be honest, is non-sense. Please do not try optimize just because you think it might be a performance problem The correct loop for optimization is: Write code -> Google how to benchmark software -> benchmark software -> find unoptimized functions -> find problems in them and fix
Gilded
ho guys whats use of learning program when chatgpt script can send anything?
Naol D
Hey man what have I done?
Gilded
the offline trained llm for guided programmatic use
Danya🔥
Hey man what have I done?
Read the rules for god's sake
Naol D
Danya🔥
inline is essential here, const is also Do not use global variables unless they are constants
Danya🔥
Do not use preprocessor for this stuff
Naol D
Okay thanks!
Danya🔥
Okay thanks!
I removed the warning because you're a sane person
Danya🔥
Lee Sin
#include<iostream> using namespace std; int main() { int year = 0,month = 0, yearLeap = 0, days = 0; cout << "What year is it?\n"; cin >> year ; cout << "What Month is it?\n"; cin >> month; //Judge leap year or not if((year%4 == 0) && (!year%100 == 0) && (year%400 == 0)) { yearLeap = 1; cout << "This is a Leap year!\n"; } else { yearLeap = 0; cout << "This is an ordinary year!\n"; } //Judge what kind of month if(month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12) { days = 31; cout << "There are " << days << " Days in that month."; } else if(month == 4 or month == 6 or month == 9 or month == 11) { days = 30; cout << "There are " << days << " Days in that month."; } else if(yearLeap == 1) { days = 29; } else days = 28; return 0; }
Lee Sin
Greetings everyone, this is a code I wrote and I have a question. At the "Judge leap year or not" part, how did the logic test go right when !year%100 ==100 should be a paradox with year%400 ==0
Lee Sin
Ya but I heard that leap year is 4n and not 100n, but 400n
\Device\NUL
Ya but I heard that leap year is 4n and not 100n, but 400n
if (year % 400 == 0) yes else if (year % 100 == 0) no else if (year % 4 == 0) yes else no Just implemented it from wikipedia
Lee Sin
Thank you, but I'm still wondering is this : if((year%4 == 0) && (!year%100 == 0) && (year%400 == 0)) the same as: if (year % 400 == 0) yes else if (year % 100 == 0) no else if (year % 4 == 0) yes else no
Lee Sin
OK!!!Thank you so much!😆
\Device\NUL
OK!!!Thank you so much!😆
You should check the bigger value first because small value can be factor of the bigger one but not the opposite.
Null
The Missing Semester of Your CS Education" is a practical and hands-on computer science class that fills the gaps in traditional CS education. This course covers essential topics often overlooked in standard curriculum, empowering students and programmers to work efficiently and effectively within the computing ecosystem. Topics include mastering the command shell for task automation, harnessing version control for collaboration and problem-solving, optimizing text editing with advanced features, managing remote machines seamlessly, streamlining file searching, data wrangling from the command line, leveraging virtual machines for experimentation, and enhancing security practices online. With 12 engaging lectures and practical exercises, this class equips participants with indispensable skills to excel in the world of computer science and programming. https://www.youtube.com/@MissingSemester/
\Device\NUL
james
Time to make perfumes: N no. of perfume bottle P.q.r are machines to make distilled and fragrance and another. t1. 12. 13 are times of machine Find the time take to n bottles of perfumes
james
please make this question
Danya🔥
please make this question
$1000 is the cost
james
Time to make perfumes: N no. of perfume bottle P.q.r are machines to make distilled and fragrance and another. t1. 12. 13 are times of machine Find the time take to n bottles of perfumes
p
#include<iostream> using namespace std; int main() { int a=2; int y=++a * ++a; cout<<a<<" "<<y; }
klimi
Read the rules about allowed languages
Dima
Read the rules about allowed languages
its c++, so you are basically right
klimi
its c++, so you are basically right
I meant the non English text?
Ziky
Why its output is 4 16
Your question explains why you or anyone else should never write code like that which is complicated to understand.
klimi
Why its output is 4 16
Because you do Int y = 4*4;
Anonymous
#include<iostream> using namespace std; int main() { int a=2; int y=++a * ++a; cout<<a<<" "<<y; }
This is Undefined Behavior. This has been explained many times before in this forum. Either search for it or read about "Order of Evaluation" in Cppreference
Lxjxjxhks
ifstream inputFile("sample_data.csv"); if (!inputFile) { cerr << "Failed to open sample_data.csv" << endl; return; } string line; while (getline(inputFile, line)) { istringstream iss(line); string token; while (getline(iss, token, ',')) { uint8_t pixelValue = stoi(token); write(pipe_fd, &pixelValue, sizeof(uint8_t)); // Sleep for 'T' milliseconds to emulate the time interval this_thread::sleep_for(chrono::milliseconds(T)); } } inputFile.close(); exit(0); }
Lxjxjxhks
//output what i get Enter the number of columns (m): 10 Enter the scan width: 2 Enter the time interval (T) in milliseconds: 10 Enter the threshold value: 90 Select data source: Generate random data Use sample 2D array from a CSV file Enter your choice (1 or 2): 2 Pixel Value: 10 Filtered Value: 0 Threshold Value: 0 Lovelys-MacBook-Air:CynLr lovel$ Pixel Value: 20 Filtered Value: 0 Threshold Value: 0 Pixel Value: 30 Filtered Value: 0 Threshold Value: 0 Pixel Value: 40 Filtered Value: 0 Threshold Value: 0 Pixel Value: 50 Filtered Value: 4 Threshold Value: 0 Pixel Value: 60 Filtered Value: 10 Threshold Value: 0 Pixel Value: 70 Filtered Value: 20 Threshold Value: 0 Pixel Value: 80 Filtered Value: 30 Threshold Value: 0 Pixel Value: 90 Filtered Value: 40 Threshold Value: 0 Pixel Value: 15 Filtered Value: 50 Threshold Value: 0 Pixel Value: 25 Filtered Value: 59 Threshold Value: 0 Pixel Value: 35 Filtered Value: 69 Threshold Value: 0 Pixel Value: 45 Filtered Value: 72 Threshold Value: 0 Pixel Value: 55 Filtered Value: 62 Threshold Value: 0 Pixel Value: 65 Filtered Value: 42 Threshold Value: 0 Pixel Value: 75 Filtered Value: 32 Threshold Value: 0 Pixel Value: 85 Filtered Value: 35 Threshold Value: 0 Pixel Value: 95 Filtered Value: 45 Threshold Value: 0 //for some reason after reading the sample_data.csv, it prints the present working directory and then it is all same, how to not have the pwd in the output, someone please help
Lxjxjxhks
notice the Lovelys-MacBook-Air:CynLr lovel$in the ouput that is pwd which i do not want in the ouput, any suggestions
Lxjxjxhks
am i doing something wrong in reading the csv file
Lxjxjxhks
// Define the filter window double filterWindow[] = {0.00025177, 0.008666992, 0.078025818, 0.24130249, 0.343757629, 0.24130249, 0.078025818, 0.008666992, 0.00025177}; int filterSize = sizeof(filterWindow) / sizeof(filterWindow[0]); vector<uint8_t> buffer(filterSize, 0); int final_val = 0; while (true) { // Read data from the pipe (data generation process) uint8_t pixelValue; ssize_t bytesRead = read(pipe_fd, &pixelValue, sizeof(uint8_t)); if (bytesRead == sizeof(uint8_t)) { // Add the new pixelValue to the buffer buffer.push_back(pixelValue); // Check if the buffer has enough data for filtering if (buffer.size() >= filterSize) { // Apply the filter double filteredValue = 0.0; for (int i = 0; i < filterSize; ++i) { filteredValue += buffer[i] * filterWindow[i]; } if (filteredValue > threshold){ final_val = 1; } else{ final_val = 0; } // Output the filtered value cout << "Pixel Value: " << static_cast<int>(pixelValue)<< " Filtered Value: " << static_cast<int>(filteredValue) << " Threshold Value: " << final_val << endl ; // Remove the oldest pixelValue from the buffer buffer.erase(buffer.begin()); } } // Sleep for a while before processing the next batch this_thread::sleep_for(chrono::milliseconds(1000)); } }
Lxjxjxhks
this is the function that prints value for further reference
Paulo
HI guys, I had made my whole background using C and C++, and I love this language, when you start realize how everything work, memory and arrays, pointers and other things, is just amaze how you start understand computer and program languages like C++. But In Brazil I had only one job working with C++, most of my Job in the last 5 years are using Java or C#, and my knowledge start become out of date, sometimes I take some task to do using C++, but the are small projects or integrations. I'm studying modern C++ and focus in high performance systems. I had understand what is move semantics and copy, the problem is, when data structure in C++ use them, like. If I'm using a vector and this vector resize, I know this will internally use move semantics to resize and move the old values, If I use emplace_back and need create specific constructors to be used by emplace_back, or it can just use move semantics and avoid the use of emplace_back. I'm studying and looking for every peace of information, so if anyome can help me sending articles or more source of information. I'll appreciate that.
Paulo
C++ keywords, features, sintaxe and OOP are not a problem for me , I'm trying understand deeply c++ data structures.
GOPA
Here I give some import YouTube and articles for c++ improvement I personally feel c++ is fast and high performance language giving high amount of control at hardware level believe this will help you
GOPA
https://youtube.com/playlist?list=PL1tk5lGm7zvSoZ_u9U_mkI5Bss45bGCyv&si=8qGHlSBfAERbmtds
GOPA
https://youtube.com/playlist?list=PLkEldc5soqvRcoiSViztJy9dlwYoV8S2t&si=y-Zbx9O2IH9ZTWpb
GOPA
https://people.cs.pitt.edu/~xianeizhang/notes/cpp11_mem.html
GOPA
https://hackingcpp.com/cpp/educational_videos.html#retro-compilers
GOPA
https://github.com/RedSkittleFox/cpp-learning-resources/blob/master/README.md#embeding-different-languages-in-c
GOPA
This is basic but it gives exposure
GOPA
Well I believe, but I may be wrong I am an undergraduate
GOPA
Try cppnuts YouTube channel
Danya🔥
We recommend sticking with the Resources channel
Paulo
We recommend sticking with the Resources channel
Ok, I'll look the resources channel.
Danya🔥
Random YouTube channels, especially Indian ones, are considered harmful by default
GOPA
thanks but i felt he had a great depth in his video after cherno
GOPA
again, something not useful to you may be useful to others
Danya🔥
Ok, I'll look the resources channel.
Also, UFMG university in Brazil has a nice laboratory on compilers, maybe they have a good C++ course and other