compile with debug mode, the program crash.
Mohamed Ahmed
What is the size of integer 2 or 4
it seems because debug mode in msvc will change the memory layout.
Leovan
What is the size of integer 2 or 4
Its depends on compilator and machine on which you work. Nowadays often is 4
There is a table
TYPE LP32 ILP32 LP64 ILP64 LLP64 CHAR 8 8 8 8 8 SHORT 16 16 16 16 16 INT 16 32 32 64 32 LONG 32 32 64 64 32 LONG LONG 64 64 64 64 64 POINTER 32 32 64 64 64
windows is often using data model llp64, and linux often using lp64
Leovan
C++ standard says only about char is equal minimum address cell, and short <= int <= long <= long long
\Device\NUL
Just use intX_t macro from stdint and you're good. Since data type is not portable
labyrinth
I would like to know about what are some of the industrial practice for heap memory management with c++
labyrinth
i saw some post decline the use of smart pointers at all, they would rather implement their own reference counting
Anonymous
hello, Anyone who is good in C language?
kamilya
hello, can you please help me find a free program to learn C code?
kamilya
phone app
Nana
Hello
Nana
Pls how can I use my object file in another c++ program?
Nana
Pls how can I use my object file in another c++ program?
pls I'm waiting for your responses
Pavel
Pls how can I use my object file in another c++ program?
Can you describe what you mean? Or give an example
Pavel
For example, object, do you mean runtime object? Or a class?
Pavel
Or by object file, you mean *.o or *.obj file?
\Device\NUL
not macro, it is typedef
Thanks for correcting ~
Nana
check the class code
a template class? or just a class?
Nana
#ifndef RECTANGLE_H #define RECTANGLE_H class Rectangle { public: Rectangle() { length = 0.0, width = 0.0; // default Rectangle class } Rectangle(double, double); double getLength() { return length; } double getWidth() { return width; } double getArea() { return length * width; } protected: private: double length, width; }; #endif // RECTANGLE_H
Nana
and finally Rectangle.cpp
Nana
#include "Rectangle.h" Rectangle::Rectangle(double len, double w) { length = len; width = w; }
Nana
Pls I'm waiting for your answers
Pavel
Pls I'm waiting for your answers
Are you doing some test right now? :)
Pavel
Or shared as part of a library also I guess (?)
Nana
Are you doing some test right now? :)
I'm learning how to reuse classes in another program
Nana
Such a class can be easily copied between projects
Pls how can I do that? Can yo give an example?
Pavel
Pls how can I do that? Can yo give an example?
It depends how you want to share, you can just copy these files and paste to the new project
Pavel
There are other possibilities, but they are more complex
Nana
It depends how you want to share, you can just copy these files and paste to the new project
Can't it be called in the new program once the class has been created using the #include "Rectangle.h"?
Nana
That is in case I want to give my class program to another programmer
Pavel
Can't it be called in the new program once the class has been created using the #include "Rectangle.h"?
You can do it like this, but then these projects are bound together, so when someone need to take one project, they need to have both. The shared part can be moved to a separate project/subrepo but then you need to manage versioning of this somehow (e.g. using git submodules).
Nana
You can do it like this, but then these projects are bound together, so when someone need to take one project, they need to have both. The shared part can be moved to a separate project/subrepo but then you need to manage versioning of this somehow (e.g. using git submodules).
The book I use has stated something like this " Separating a class into a specification file and an implementation file provides a great deal of flexibility. First, if you wish to give your class to another programmer, you don’t have to share all of your source code with that programmer. You can give him or her the specifica tion file and the compiled object file for the class’s implementation. The other programmer simply inserts the necessary #include directive into his or her program, compiles it, and links it with your class’s object file. This prevents the other programmer, who might not know all the details of your code, from making changes that will introduce bugs. "
Pavel
Pls you mean you need to give both the implementation and the specification file to the programmer who wishes to use your class file?
Yes. The thing with header file (Rectangle.h) that it's the only information that is needed to use this class, all the implementation details are hidden in Rectangle.cpp. So the other programmer don't need to think about the content of the *.cpp file. But the compiler/linker of the other programmer still needs the Rectangle.cpp unless you compile it into a library and provide that library to the other programmer and that they need to link to their app.
Grigoriy
How can I define my own clock type if epoch of system_clock is unspecified (untill c++20)? I can't write the function my_clock::now() because of that.
Pavel
Yoooo someone's toes got stepped....
It just very not comfortable when you get a phonecall because you haven't answered someone on the internet :) It could be night for me as well :)
labyrinth
vector<int> ({})[26]; this piece of code can compile but I dont understand it
Jojo
Is it possible to add code to smartphone apps or twerk them like adding new functionality
Misagh
vector<int> ({})[26]; this piece of code can compile but I dont understand it
std::vector<int>() default constructs a temporary vector. std::vector<int>({}) passes an empty list to the initializer-list constructor of vector. std::vector<int>({})[26] makes an array of those.
labyrinth
got it, so {} can be replaced with any other legal constructor arguments, but how to make it named?
labyrinth
vector<int> (26,0) [26]; means making an array of vectors, each of which has 26 zeros, but I cant make it named
Misagh
vector<int> (26,0) [26]; means making an array of vectors, each of which has 26 zeros, but I cant make it named
That's a good question. It seems that I was wrong actually. std::vector<int>(CTOR)[26] doesn't make an array, but calls vector's operator[] on the temporary. std::cout << std::vector<int>(10, 33)[2]; //prints 33 And I don't think it's possible to make an array out of a constructed vector. compiling std::array<std::vector<int>(26, 0), 26> name; gives an error that temporary of non-literal type 'std::vector<int>' cannot be used in a constant expression.
Stas
Hi. I would like to know if someone of you has been used conan with openblas and armadillo on linux machine ?
Amonov
Hello everyone
Jojo
Yo
ㅤㅤㅤ
Is auto in for loop advance version of i version. Or is it from STL in C++
\Device\NUL
\Device\NUL
It just the compiler will automatically define its type like type inference in Go
\Device\NUL
Okay got it. Is it same as i=0;i<n;i++
No it's not for (auto i = 0;;) is different with for (i =0;;)
\Device\NUL
The first loop, after the loop end, i is no longer can be accessed since its scope only in loop
Abid
Pleaze help me to get free liscece key for intelij ide
Anonymous
shriman_deepak
Hello Guys I want to take arguments from the command line and check whether it is integer or not. How can i do this ?
shriman_deepak
#include<stdio.h> #include<stdlib.h> #include<ctype.h> int main(int argc, char* argv[]) { if ( argc == 3) { if ((isdigit(argv[1])) && (isdigit(argv[2])) ) { // printf("%d ",argv[1]*argv[2]); } else { printf("Please enter integer values only \n"); } } else { printf(" Invalid Number of arguments \n "); } return 0; }
shriman_deepak
I have done this but it's not working
Anshul
https://pastebin.com/kt01Y3DS
Anshul
in this code i don't understand why i need to make compare function as static? ( i tried to submit it without making compare function as static but it gives error
Anshul
btw the entire code is written inside a class Solution{}
Anonymous
Hello everyone
Anonymous
I am beginner how i can improve my c++ programming language
Anonymous
I need help