By default Sublime Text does not build C++ with C++ 11 features. Follow below steps to activate the c++ 11 building feature in Sublime Text 3. Steps are tested on Windows. I don’t think this will be too different on Mac or Linux except the shortcut.
- Install PackageResourceViewer plugin
- Open the command center by entering Ctrl + Shift + p
- Type “PackageResourceviewer: Open Resource”
- Then C++ –> C++ Single File.Sublime-build , this will open the build config file for C++
- Where ever you g++ add -std=c++11 infront of it and save the file
Recently while working in Linux, accidentally I created a folder named “–versionset”. I was quite a tuff task to delete the folder as this name is parsed as option to rm command. After searching a bit found a solution in stackoverflow to disable dashes during the parsing. Here is the command you need to use to remove a file starting with dashes.
rm -rf -- --versionset
— in the command deactivates the parsing the dashes in the file name.
Following are few Important classes in Qt which might come very handy while developing Qt GUI application.
Use the following rules to decode pointer types in expressions:
The best way to read a type is from left to right. A few examples:
int const x = 9; – the const applies to whatever appears to its left, therefore the int is const
int const *p = &x; – again, the const applies to the int, not to the pointer. You can change the value of p but not the value of whatever p points to
int *const g = &i; – const applies to the pointer, not to the int. You can change the value pointed by g but you can’t change the pointer g
The same rule can be used to read references and pointers to pointers:
int **h; – read from right to left: a pointer to a pointer to an int
int const *const *r; – a non-const pointer to a const pointer to const int
int const &a; – a reference to a const int
int const *n; – a non-const pointer to a const int. You can change the pointer but you can’t change the value of what it points to
int const *&k = n; – a reference to a non-const pointer to a const int. You can’t change the value of what the pointer points to. Since you have a reference to a pointer, changing k will also change the pointer n
The only exception to that rule is when there’s nothing to the left of a const, in which case the const is applied to whatever appears to its right:
const int x = 9; – the const applies to the int
const int *p = &x; – again, the const applies to the int, not to the pointer. You can change the value of p but not the value of whatever p points to
const int const y = 10; – compilation error: both consts apply to the int
const int const *g = &x; – again, a compilation error: both consts apply to the int, not to the pointer
All the information is derived from the below Quora post. All credit goes to the original author of the post.
In the above program comment out line no 14 and 18 for successful compilation.
Pointers can be of two types
1. Constant Pointer: In this case the pointer is constant, this is similar to ‘const int’. So, this type of pointers should initialized at the point of definition and only point to a single memory location through out the life time.
2. Pointer to Constant: In this case the pointer is pointing to a read only memory location, i.e it’s holding memory location of a constant. This type of pointers behave like a normal pointer but you can’t assign a new value by pointer de-referencing ‘*’ operator.
We will go in reverse way. What would have happened if cd was implemented as a external command. Bash has to fork a new process and that process will run cd, which in tern change the folder to the destination location. What ever folder change happened that is only effective for the child process and our original process which forked the cd process still in the old directory. So, at the end of the cd execution we are still inside the old folder.
This is the reason why cd is shell in-build function. There are hack which can have the same effect of cd when implemented as external process but that requires more complex coding.
Given a string, print all a string with words in reverse.
Input: “Hello how are you”
Output: “olleH woh era uoy”
This problem requires simple tree traversal and keep the record of the maximum sum, and update the sum as you traverse the tree.
You need to generate numbers in a range in lexicographical order. For example if 25 is given then following will the output of the program.
Consider following two dimensional array:
1 2 3
4 5 6
7 8 9
You program should print : 1 2 3 6 9 8 7 4 5