I am declaring a global variable, first_clauses
:
vector<vector<int>> first_clauses; //clauses for first iteartion
Now, cnf_transformation
is one of the functions of the program:
void cnf_transformation(vector<vector<string>> gates, vector<vector<int>> first_clauses)
{
for (int i = 0; i < gates.size(); i++)
{
if (gates[i][1] == "AND" || gates[i][1] == "and")
{
vector<int> cl;
cl.push_back(-1 * umap_toInt[gates[i][2] + "_a_1"]);
cl.push_back(-1 * umap_toInt[gates[i][3] + "_a_1"]);
cl.push_back(umap_toInt[gates[i][0] + "_a_1"]);
first_clauses.push_back(cl);
cl.clear();
cl.push_back(umap_toInt[gates[i][2] + "_a_1"]);
cl.push_back(-1 * umap_toInt[gates[i][0] + "_a_1"]);
first_clauses.push_back(cl);
cl.clear();
//many more lines are there
}
I want to push some required data into the global variable first_clauses. So, I am calling cnf_transformation
and my second argument is first_clauses
:
cnf_transformation(gates, first_clauses);
Now, when I print the first_clauses
data structure inside my function, it is actually storing data but, after coming out of the function, my global variable first_clauses
is not updated. I am still learning C++. Please guide me.