No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
68 Posted Topics
I am parsing below sample file in below code snippet. {"requestType":"INVOCATION", "hostName":"localhost", "serviceName":"bucky", "serviceType":"DISCRETE", "serviceParameters":"sampleData", "servicesList" :[ { "serviceName" : "ABC", "serviceParameters" : {"para1" : "value1", "para2" : "value2", "para3" : "value3"} }, {"serviceName" : "CBA", "serviceParameters" : { "para1" : "value90", "para2" : "value", "para3" : "value"} } ], … | |
In below code while compiling i am getting error , Error : main.cpp:8:57: error: expected type-specifier before ‘Staircase’ std::unique_ptr algodiagnostic (new Staircase()); compilation command g++ HardwareDiagnostic.cpp HardwareDiagnostic.h main.cpp -std=c++0x -o res it works fine if compile entire code in single file without creating header file and main.cpp separately. Can anybody … | |
Hi All, I am looking for a design approach to implement TCP socket server which is going to serve requests based on multiple ports. (1) port1 : dedicated for video streaming (2) port 2: dedicated for audio streaming (3) port 3: dedicated for data streaming. In above scenario do i … | |
In below code i am writing file contents in backup serialize file through boost serialization library, but what i observed that every time i need to store all the data in file then only i would be able to read the entire data. so in case if i perform single … | |
Hi, Below command will give the cpu and memory usage of process in terms of percentage. can we achieve same usin c/c++ API. ps -C <process name> -o %cpu,%mem | tail -n 2 | |
I am looking for log archival utility or approach which should be able to help me in based on below policy. (1) whenever log file (system.log) size >30859 or file is 3 day old then it should archive the same with new name system.log1 and again start the feeding the … | |
Hi, i want to truncate the log file which is already in use ( log is getting appended) . After that i want to make sure log is still getting appeneded after performing truncate. I have been using below command for the same but don't see it is happening. truncate … | |
Hi All, In below code i am getting ouput of process (based on name) memory and cpu utilization % using command "ps -C gnome-terminal -o %cpu,%mem | tail -n +2" .Here gnome-terminal is name of process for that i am printing these values. Now i want to implement the same … | |
Hi All, I have to implement string class and write a program to perform string manipulation in Mystring class. input: "he is going to school" output Case 1: (n=1) He school to going is Case 2: (n=2) He is school to going Case 3:(n=5) No changes Case 4 n<=0 school … | |
Hi All, i am curious to know how to set the value (value=10) through B's constructor in below programme. below is example of multiple inheritance. As construction always happens from right to left so it always call the 'C' class's constructor and set the value 20 but as per my … | |
Hi, I would linke to know what is the best way to synchronise the shared memory segment. is threads usage are also advisible whie synhcronising the shared memory segement. in what circumstances we should use threads or semaphore to synchronize the memory segment. | |
In below code snippet , I am trying to add the intefeger and float values in Array template but was surprised to see below output for float value as 5.1 was expected there but getting 0 . Can anybody let me know what can be wrong here. output value=5 value=15 … | |
Hi All, I below code snippet I have been using diff-2 structure with same variable due to having different -2 default values for the variable (var) in current implementation for both the structure a and b. This way i need to create 17 structure with same variable (var) but different … | |
Hi All, in sqlite SMALLINT datatype is used to store 2 bytes integer but i didn't see any Unsigned SMALLINT type to support the range(0-65535). Can anybody let me know how to achieve the same. | |
Hi, I need to make sure my integer variable doesn't store more than 2 bytes. Usually i am writing programme on Linux machine where integer size is 4 byte. Each byte can take the values 0 through 255 (=2^8-1). So, two bytes can take the values 255*255=65535, so would it … | |
Hi All, In below code when class a object is assigned to class b by returning object through factory method i observed assignment is not happening properly and after assignment still class b's object points to NULL object only. *cobj=rhs;//it gives NULL object However below statement works perfectly when b … | |
Hi All, After compiling below code , I am getting below error. error: cannot convert a* to b* in assignment. it seems to be assignment doesn't work with pointers . Can anybody throw some light on this? i tried to use unique_ptr by transfering the ownership from a to b … | |
Hi All, Below is the code of implementation of aggregation in c++. In this code class bar object will be contained in class a but class a won't act as a owner of class bar and due to this bar object is deleted after class a's life time ends. Now … | |
Hi All, In below code i am surprised to see destructor for rectangle class is not being called though base class destructor for IShape is virtual. below is the output of below programme: draw the rectangle draw the circle draw destructor deleting circle **deleting the Rectangle** is missing from output … | |
Hi All, In below design i would like to know the appraoch of deletion of base class pointer .It is pritty clear that deletion of base class object obj won't take place inside Draw destructor. Apart from this same code i have tested using unique_ptr and as expected it is … | |
Hi All, In below code i am performing search in map through key value but not able to get the desire results though common elements (intersection) is present in both lists. #include <iostream> #include <stdio.h> #include <stdlib.h> #include <map> using namespace std; struct node { int data; struct node* next; … | |
Hi All, In below code snippet multithreading is used to take care of multiple requests from client. I beileve creating and detaching thread will eat lots of CPU cycle and it won't improve the CPU utilization as well. Can anybody let me know if thread pool can be used here … | |
Hi All , In below code i am getting error while assigning one object with other and result is clear as both objects are different types. it is expected that RHS object should belong to same class. How to resolve this issue. error: no match for operator= in obj1 = … | |
Hi All, I wanted to know in below code snippet what will be impact if m_singleObject is declared as a weak_ptr. Usaually we peform lock on weak_ptr and convert the same in to the shared pointer and then return the same to GetInstance() function. static std::shared_ptr<singleType> shareObject = m_singleObject.lock why … | |
Hi All, I just want to know whether use of shared_ptr is justified in below code here or do i need to use unique_ptr instead of shared_ptr? #include <iostream> #include <memory> using namespace std; class a { int a1 ,b; public: a(int x=0,int y=0):a1(x),b(y){} void fun1() {cout<<a1;cout<<b;} }; class b … | |
Hi, Guys i just wanted to know whether set store elements in specific order or it contains unordered elements only. As per c++ specification http://www.cplusplus.com/reference/set/set/?kw=set Sets are containers that store unique elements following a specific order. As per my knowledge they are not ordered in the sense that you can't … | |
Hi, In below design a big problem is whenever DoSomething() signature is changed to introduce new functionality caller class (return m.DoSomething()) also needs to be changed which might not be aware of this change. kindly suggest good design to get rid of this flaw. class MyOtherClass { int m; public: … | |
Hi, In below function i am not able to figure out why predicate function cmp_str can't be used with for_each algoritham while using this algoritham with map. #include <iostream> #include <map> #include <utility> using namespace std; struct cmp_str { bool operator()(string a, string b) { return a.compare(b)<0; } }; int … | |
Hi All, I am new to thread programing. In below code snippet inside producer thread if return NULL statement is removed i observed programme is hanging. Usually after execution of pthread_cond_signal(&cond); i believe i am out of this thread and consumer thread already have taken proper exit after execution of … | |
Hi , Below is the code of template smart point implementation. in below code snippet we are not allocating any memory in smart pointer constructer for ptr but still delete is called in destructor for ptr. Is it right way to implement the same ? can we delete the pointer … | |
Hi Guys, In my current task , I need to read the read the approximately 10,000 recoreds from database and need to store the same in container.Now i need to select container to store all this records inorder to generate the report.Could you let me know whether i need to … | |
Hi All, Usually in factory method we need to check the existance of object based on given argument and then need to return the object and due to this we need to have multiple if and else statement and while adding one more type then again one more else block … | |
Hi All, in below code snippet, I have been facing memory leak issue while free memory for string.Could you let me know thereason for the same.I believe if we are allocating memory then it needs to be freedbut what i observed if i don't free the memory it works fine … | |
Hi, in below code snippet i am trying to resume again forground process by issuing fg %1 in code but still it doesn't work. usually after issuing fg %1 from command prompt it should alwaysstart first suspended process but same is not happening and i am getting error like ; … | |
Hi All, I am writing hash function (similar to multimap concept of c++ : duplicate keys are allowed) in order to check the anagrams. but i am not getting desired result . Could you suggest efficient solution for the same. output: key[148]:val[joy] key[174]:val[jam] key[294]:val[paula] key[13]:val[ulrich] key[174]:val[cat] key[174]:val[act] key[148]:val[yoj] key[265]:val[vij] key[265]:val[jiv] … | |
guys, I am implementing hash function in below code snippet but unfortunetly getting segmentation fault. Could you please help me to understand that what went wrong in this implementation. #include<stdio.h> #include<string.h> #include<stdlib.h> unsigned long hash(char** str ) { unsigned long hash_val = 5381; unsigned long sum=0; char* val ; int … | |
Hi All, In below code snippet i am getting segmentation fault. Could you let me know what can be cause. usually we will face segmentation fault if auto_ptr is used due to ownershpt issue (Assignee pointer becomes NULL) but why i am facing the same issue with unique_ptr move semantics. … | |
Hi All, in below class i wanted to have two friend function(overloading) one with default argument and other is without default argument. but during compilation it gives error. could you let me know how to fix (overload) this by not changing the function name , argument type or number of … | |
Hi All, I know this is very silly question about singleton pattern but still it is first choice of interviewer. Could you let me know in below code snippet. (1) After deleting singleton object why still i am able to call show() method and it works fine. delete obj; obj=NULL; … | |
Hi, As we know constructor doesn't have any return value so it is not good idea to perform exceptional handling inside constructor.SO i would like to know if i am opening a file inside constructor and due to some reason (file not exist) failure happened inside constructor then how to … | |
I want to ask how to pass the '30','31','32' to SQL WHERE IN clause For example EXEC SQL DECLARE abcd CURSOR FOR SELECT Consignment FROM Transaction WHERE order_type IN (:dest) where dest will hold the value '30','31','32'. I have tried as above example but it is not working SQL did … | |
My XSLT is like: <!DOCTYPE stylesheet [ <!ENTITY hyphen "<xsl:text>-</xsl:text>"> <!ENTITY cr "<xsl:text> </xsl:text>"> ]> <xsl:stylesheet id="test" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://exslt.org/common" exclude-result-prefixes="ext" version="1.0"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:variable name="vc_NDCROI" select="'NDC05'" /> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="node()|@*" mode="mPass2"> <xsl:copy> <xsl:apply-templates select="node()|@*" mode="mPass2"/> </xsl:copy> </xsl:template> <xsl:template match="/"> <xsl:variable name="vrtfPass1Result"> … | |
Hi Guys, I am trying to create array of 9 strings dynamically in below code snippet but while accessing elements i am getting all the elements null instead of accessing actual element of array.Please suggest. #include<stdlib.h> #include <stdio.h> #include <string.h> int main() { char **arrayofstr; char str[250]={0,}; int i; for … | |
Hi Guys, In below code you can see that i am able to execute the functionality of class a , inside the class b through composition and object of b can be used to call the methods declared inside the a class. #include <iostream> using namespace std; class a { … | |
Hi guys, I would like to discuss my design with one query. below is the code snippet. It is clear from below code snippet that class pd is privately derived from AbstractClass as both are different classes and there is no relation between them.Now in my class pd i need … | |
Hi guys, I want to access the element of structure from structure pointer using indexing for below code snippet. apart from this I also would like to know is there any way to find the type of member variable of structure on run time. #include <stdio.h> #include <assert.h> #include <stdlib.h> … | |
Hi Guys, Any body knows what is the efficient way to create the map (key,value pair ) using linklist using c .Apart from this in this map one key can have multiple values and i need to display those values. I don't want implementation in c++. example string1->"james" string1->"mike" string1->"harry"; | |
Guys, In below code after reading string values from vector , I can have output like("VarID","flag","count") for(int i=0; i < v.size(); i++){ cout<<v[i]<<endl; } All are (varID,flag and count)are string literal , now i need to populate the structre with this string literal. where VarID = int,flag=bool, count=Int. Can anybody … | |
Guys, In below code they are couple of issues. (1) I am not able to read first key and value pair record from snmp.json file in my map, it just start reading after first record. (2) After reading the value from file in current implementation it is not reading the … | |
Hi Guys, I am looking for protocol conversion mechanism for my below requirement. Can somebody throw light on this as I am newbie for SNMP. I will appreciate your pointers for this requirement. Protocol Mapper: 1. The Mapper is a configuration file created by user to perform the protocol translation … |
The End.