Monday, November 4, 2013

are all options in CMakelists.txt necessary?

i edited file CMakeLists.txt given at  http://pointclouds.org/documentation/tutorials/using_pcl_pcl_config.php#using-pcl-pcl-config

i removed the line
link_directories(${PCL_LIBRARY_DIRS})
 
the code still compiled well in console & eclipse.It ran fine in both.how is this possible?

it could be possible that cmake looks for link directories in some default places & if libraries are found in these default locations then, the code is compiled & run even if the link directories are missing.


when i ran the cmake xaple form cmake tutorial at: http://web.cs.swarthmore.edu/~adanner/tips/cmake.php


i removed the link_libraries option & i got the following error

[ 60%] Building CXX object CMakeFiles/oglfirst.dir/oglfirst.o
Linking CXX executable oglfirst
CMakeFiles/oglfirst.dir/oglfirst.o:oglfirst.cpp:function display(): error: undefined reference to 'glClear'

....
collect2: ld returned 1 exit status
make[2]: *** [oglfirst] Error 1
make[1]: *** [CMakeFiles/oglfirst.dir/all] Error 2

Saturday, November 2, 2013

Friday, November 1, 2013

Thursday, September 19, 2013

c++ online course

error messages & corrections



  1. error: declaration of ‘std::string GradeBook::getCourseName()’ outside of class is not definition [-fpermissive]:cause: semicolon in function definition in class implementation
  2. error : undefined refernce to class member.cause : constructor with no arguments was called as GradeBook my GradeBook();Eclipse gave an error for the same
  3. Time.h:24:11: error: ISO C++ forbids in-class initialization of non-const static member initialsing data members of a function: cause initialising data member of a class

Friday, September 13, 2013

questions


  1. can we have multiple constructors?
  2. how to ensure that multiple copies of same #include is not added to the code?
  3. do we need to declare a destructor both in the header & cpp file
  4. what is file scope?
  5. what is the difference b/w string & const string &?where do we use each?

daily learning


  1. When declared in header file the constructor has first bracket around it.
  2. the constructor initializes all data members of the object.the data members are provided as arguments to the constructor
  3. constructors when defined in a header doesnt require parameter names.only parameter type is needed
  4. if a constructor takes no arguments , then while calling it just use the name without any arguments.for eg GradeBook myGradeBook; & not GradeBook myGradeBook();.Eclipse gives an error for the same.
  5. each function in the implementation of a class is preceeded by class name followed by ::
  6. however if a function is called by a member of the same class then the classname & semicolon is omitted
  7. in the implementation of the class in the cpp file, we have to define the parameter type in each definition like void GradeBook::setCourseName(string new).This is despite the fact that we have declared the parameter type in the function interface.This is because of the fact that function overloading can happen, where the same function takes different parameters to function.
  8. Both the class interface & implementation end with semicolon(;).
  9. in the class implementation we must include scope, return type & parameter (with name)
  10. when the program is broken into main & other functions, it can be compiled using g++ main.cpp other.cpp.adding the header is not needed.i got error undefined reference to `GradeBook::GradeBook when i didnt add the other.cpp file.the other.cpp file had the class member function definition
  11. cin is an object of <istream>.istream member functions are get,getline, getblock etc.
  12. when using switch-case dont forget to add the default case.also dont forget the curly brackets for the switch statements
  13. we use const to a function to say that no data is modified in that function.This is done in function declaration in header as well as the function definition.
  14. destructor is created automatically by the compiler.however if it declared explicitely in the code then we need to define it in the member function declaration as well.it may have an empty body though.